Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf DataGridCheckBoxColumn NotifyPropertyChanged立即单击_Wpf_Xaml - Fatal编程技术网

Wpf DataGridCheckBoxColumn NotifyPropertyChanged立即单击

Wpf DataGridCheckBoxColumn NotifyPropertyChanged立即单击,wpf,xaml,Wpf,Xaml,您好,我有一个DataGridCheckBoxColumn,我希望它在用户检查或取消选中DataGridCheckBoxColumn时立即通知底层绑定对象上的PropertyChanged 目前,只有当用户在选中或取消选中DataGridCheckBoxColumn后单击另一行时,才会出现这种情况 XAML: 将绑定的UpdateSourceTrigger更改为propertychanged,而不是保留默认的lostfocus 您必须使用列模板而不是复选框列来指定此项 <dg:DataGr

您好,我有一个DataGridCheckBoxColumn,我希望它在用户检查或取消选中DataGridCheckBoxColumn时立即通知底层绑定对象上的PropertyChanged

目前,只有当用户在选中或取消选中DataGridCheckBoxColumn后单击另一行时,才会出现这种情况

XAML:


将绑定的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>