如后面的加号,选中行时出现,未被选中的隐藏
解决:
在按钮中的visibility属性中绑定该item是否选中,再用转换器转换
<Button Name="btnA" Click="btnA_Click_1" BorderBrush="Transparent" BorderThickness="0" Background="Transparent" Visibility="{Binding RelativeSource={RelativeSource AncestorType=ListViewItem}, Path=IsSelected,Converter={StaticResource btnshowConverter}}">+</Button>
public class btnshowConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value.ToString() == "True") return "Visible";
if (value.ToString() == "False") return "Collapsed";
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}