绑定到自身,设置转换器,设置borderThickness
<Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self},Converter={StaticResource ListBoxTableBorderConverter}}"/>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
ListBoxItem item = (ListBoxItem)value;
ListBox listView = ItemsControl.ItemsControlFromItemContainer(item) as ListBox; // Use the ItemsControl.ItemsContainerFromItemContainer(item) to get the ItemsControl.. and cast
// Get the index of a ListViewItem
int index = listView.ItemContainerGenerator.IndexFromContainer(item); // this is a state-of-art way to get the index of an Item from a ItemsControl
//使用index返回不同表框
return new Thickness(0,0,0,1);
}