调用OnPropertyChanged时,DataGrid调用CancelEdit

时间:2014-06-09 15:38:54

标签: c# wpf mvvm datagrid inotifypropertychanged

我有一个简单的DataGrid,它绑定到CollectionViewSource.View

<DataGrid ItemsSource="{Binding Path=MyCollectionViewSource.View, UpdateSourceTrigger=PropertyChanged}">
    <DataGrid.Columns>
        <DataGridTextColumn Header="Name" Binding="{Binding Path=Model.Name, UpdateSourceTrigger=LostFocus, Mode=TwoWay}"
    </DataGrid.Columns>
</DataGrid>

CollectionViewSource.Source等于ObservableCollection<ViewModel>

private CollectionViewSource _myCollectionViewSource= new CollectionViewSource();
public CollectionViewSource MyCollectionViewSource
{
    get { return _myCollectionViewSource; }
    set { _myCollectionViewSource= value; }
}
public MainViewModel(ObservableCollection<ItemViewModel> coll)
{
    MyCollectionViewSource.Source = coll;
}

我的ItemViewModel班级实施INotifyPropertyChangedIEditableObject

public class ItemViewModel : ViewModelBase, IEditableObject, INotifyPropertyChanged

出于某种原因,当我致电OnPropertyChanged("SomeObjectInsideViewModel");时,系统会调用ViewModel&#39; CancelEdit

为什么CancelEdit内的内容发生变化时会调用ViewModel

0 个答案:

没有答案