gridview 選中某行後 某行的按鈕顯示,無選中則隱藏
阿新 • • 發佈:2019-04-27
con alt tor string glob obj item 出現 nsh
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
如後面的加號,選中行時出現,未被選中的隱藏
解決:
在按鈕中的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";
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
gridview 選中某行後 某行的按鈕顯示,無選中則隱藏