【问题标题】:How to notify GUI changes with INotifyPropertyChanged immediately如何立即使用 INotifyPropertyChanged 通知 GUI 更改
【发布时间】:2014-01-18 13:00:16
【问题描述】:

在我的视图中,我有一个绑定到 Datagrid 的 ObservableCollection,每个元素都有一个 Bool 属性 IsSelected 绑定到 DataGridCheckBoxColumn,直到这里一切都作为 MVVM 必须工作。但我的问题是INotifyPropertyChanged 不会在用户更改我的DataGridCheckBoxColumn 后触发,它仅在失去焦点时触发。

如何强制网格立即通知更改,而不是在列失去焦点时通知?

我正在尝试设置

NotifyOnSourceUpdated=true
NotifyOnTargetUpdated=true

这是我的专栏

<DataGridCheckBoxColumn Header="{x:Static resources:Labels.TESORERIA_AplicarTodo}"
                        Binding="{Binding Path=Seleccionado,NotifyOnSourceUpdated=True,NotifyOnTargetUpdated=True,NotifyOnValidationError=True}"/>

【问题讨论】:

    标签: c# wpf mvvm


    【解决方案1】:

    您需要在绑定上将 UpdateSourceTrigger 设置为 PropertyChanged

    UpdateSourceTrigger = PropertyChanged
    

    【讨论】:

      【解决方案2】:

      尝试设置UpdateSourceTrigger的Binding like

      Binding="{Binding Path=Seleccionado,UpdateSourceTrigger=PropertyChanged,NotifyOnSourceUpdated=True,NotifyOnTargetUpdated=True,NotifyOnValidationError=True}"
      

      【讨论】:

        猜你喜欢
        • 2011-12-20
        • 2018-06-22
        • 2012-01-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-11-16
        • 2023-03-11
        相关资源
        最近更新 更多