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