我有ItemsControl
一个关联DataTemplate
如下。我的问题是如何以ItemsControl
不同的方式设置第 N 个项目的样式?我试图仅在某些项目上设置边框。
<DataTemplate x:Key="CTemplate">
<Grid HorizontalAlignment="Left" Width="200" Height="Auto" Margin="0,0,30,30">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Grid.Column="0">
<TextBlock Text="Device Name:" Style="{StaticResource i2_TB}"/>
<TextBlock Text="Device ID:" Style="{StaticResource i2_TB}" />
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="2">
<TextBlock Text="{Binding DeviceName}" Style="{StaticResource i2_TB}" TextTrimming="CharacterEllipsis" />
<TextBlock Text="{Binding DeviceID}" Style="{StaticResource i2_TB}" TextTrimming="CharacterEllipsis" />
</StackPanel>
</Grid>
</DataTemplate>