XAML的代码
<ItemsControl x:Name="If" lternationCount="{Binding Path=LocationNums.Count}"
ItemsSource="{Binding LocationNums}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border x:Name="Bd" BorderBrush="Black" BorderThickness="{Binding RelativeSource={RelativeSource TemplatedParent},
Path=(ItemsControl.AlternationIndex),
Converter={StaticResource BorderThicknessConverter}}">
<TextBox Text="{Binding Content}" >
</TextBox>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
converter的代码
public class BorderThicknessConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
int index = int.Parse(value.ToString());
if (index != 0)
{
return new Thickness(1, 0, 0, 0);
}
else
{
return new Thickness(0, 0, 0, 0);
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
标签:return,itescontrol,代码,object,value,分隔符,WPF,public From: https://www.cnblogs.com/HRDK-CADeveloper/p/18609316