Wpf DataGridCheckBoxColumn NotifyPropertyChanged立即单击
您好,我有一个DataGridCheckBoxColumn,我希望它在用户检查或取消选中DataGridCheckBoxColumn时立即通知底层绑定对象上的PropertyChanged 目前,只有当用户在选中或取消选中DataGridCheckBoxColumn后单击另一行时,才会出现这种情况 XAML:Wpf DataGridCheckBoxColumn NotifyPropertyChanged立即单击,wpf,xaml,Wpf,Xaml,您好,我有一个DataGridCheckBoxColumn,我希望它在用户检查或取消选中DataGridCheckBoxColumn时立即通知底层绑定对象上的PropertyChanged 目前,只有当用户在选中或取消选中DataGridCheckBoxColumn后单击另一行时,才会出现这种情况 XAML: 将绑定的UpdateSourceTrigger更改为propertychanged,而不是保留默认的lostfocus 您必须使用列模板而不是复选框列来指定此项 <dg:DataGr
将绑定的UpdateSourceTrigger更改为propertychanged,而不是保留默认的lostfocus 您必须使用列模板而不是复选框列来指定此项
<dg:DataGridTemplateColumn>
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Path=isVisible,UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
public bool isVisible
{
get
{
if (this.Visibility1 == Visibility.Visible)
{
return true;
}
else
{
return false;
}
}
set
{
if (value == true)
{
this.Visibility1 = Visibility.Visible;
}
else
{
this.Visibility1 = Visibility.Collapsed;
}
this.NotifyPropertyChanged("isVisible");
}
}
<dg:DataGridTemplateColumn>
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Path=isVisible,UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>