0
我有silverlight应用程序,其中我已经添加了一个切换按钮来扩大row.at同时我有2个文本框和1个按钮在同一row.my切换按钮工作正常,但是当我点击文本框或按钮行得到扩大,这不应该发生。行必须展开切换按钮点击only.plz指导我呃我错了。 我的切换按钮被添加像下面 的.xamlDatagrid行扩展行silverlight中点击
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ToggleButton Style="{StaticResource PlusMinusToggleButtonStyle}" Loaded="ToggleButton_Loaded" />
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
和的.cs代码如下
private void ToggleButton_Loaded(object sender, RoutedEventArgs e)
{
ToggleButton button = sender as ToggleButton;
DataGridRow row = button.FindAncestor<DataGridRow>(); //Custom Extension
row.SetBinding(DataGridRow.DetailsVisibilityProperty, new System.Windows.Data.Binding()
{
Source = button,
Path = new PropertyPath("IsChecked"),
Converter = new VisibilityConverter(),
Mode = BindingMode.TwoWay
});
}
和接口的IValueConverter实现如下
public class VisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if ((bool)value) return Visibility.Visible;
else return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if ((Visibility)value == Visibility.Visible)
return true;
else return false;
}
}
我需要什么条件检查转换和ConvertBack.or如何我可以检查点击对象是切换按钮,而不是其他按钮
没有working.When我在其他按钮单击然后ConvertBack是invoked.and展开该行。 – user484948