我已经实现了INotifyPropertyChanged ,我的GUI中的更新工作正常。 如果视图模型更改了值,则窗口中的控件将更新。
但是,我也有一个DataGrid控件,视图模型中的更新不会传播到GUI。 如果我在表中更改了某些内容并调用了存储,则更改的值可用于VM,包括新添加的行。
我看过其他类,比如INotifyCollectionChanged,但没有明白。 我应该移动并使用ObservableCollection还是有更推荐的方法?
I've implemented INotifyPropertyChanged and the update in my GUI works as supposed to. If the view model changes a value, the control in the window updates.
However, I also have a DataGrid control and the update in view model doesn't propagate to the GUI. If I change something in the the table and invoke store, the changed values are available for VM, including newly added rows.
I've looked at other classes, like INotifyCollectionChanged but got no wiser. Should I move over and use ObservableCollection or is there a more recommended approach?
最满意答案
IObservable是通知View of changes的方法。 正如您所提到的,您的模型已经实现了INotifyPropertyChanged,因此您可以充分利用它。
IObservable is the way to go to notify the View of changes. As you have mentioned you models are already implenting INotifyPropertyChanged, so your in a good spot to take advantage of it.
控件由INotifyPropertyChanged更新,但不是DataGrid中的列表(Controls are updated by INotifyPropertyChanged but not the list in the DataGrid)我已经实现了INotifyPropertyChanged ,我的GUI中的更新工作正常。 如果视图模型更改了值,则窗口中的控件将更新。
但是,我也有一个DataGrid控件,视图模型中的更新不会传播到GUI。 如果我在表中更改了某些内容并调用了存储,则更改的值可用于VM,包括新添加的行。
我看过其他类,比如INotifyCollectionChanged,但没有明白。 我应该移动并使用ObservableCollection还是有更推荐的方法?
I've implemented INotifyPropertyChanged and the update in my GUI works as supposed to. If the view model changes a value, the control in the window updates.
However, I also have a DataGrid control and the update in view model doesn't propagate to the GUI. If I change something in the the table and invoke store, the changed values are available for VM, including newly added rows.
I've looked at other classes, like INotifyCollectionChanged but got no wiser. Should I move over and use ObservableCollection or is there a more recommended approach?
最满意答案
IObservable是通知View of changes的方法。 正如您所提到的,您的模型已经实现了INotifyPropertyChanged,因此您可以充分利用它。
IObservable is the way to go to notify the View of changes. As you have mentioned you models are already implenting INotifyPropertyChanged, so your in a good spot to take advantage of it.
发布评论