我有DataGrid控件
<DataGrid Name="dataGrid" ItemsSource="{Binding Faculties}">
<DataGrid.Columns>
<DataGridTextColumn Header="Название" Width="*" Binding="{Binding Title, UpdateSourceTrigger=LostFocus, Mode=TwoWay}"/>
</DataGrid.Columns>
</DataGrid>
和查看模型
private ObservableCollection<Faculty> faculties = new ObservableCollection<Faculty>();
public ObservableCollection<Faculty> Faculties
{
get { return faculties; }
set
{
faculties = value;
RaisePropertyChanged("Faculties");
}
}
教师班:
public class Faculty
{
public string Title { get; set; }
}
如何将DataGrid中的更改保存到我的收藏中?双向绑定无济于事
答案 0 :(得分:0)
不幸的是,您的Faculty
类应该实现INotifyPropertyChanged
接口以使其正常工作。 (ObservableCollection
只会在集合本身发生变化时强制更新 - 添加或删除元素 - 并且当集合中元素的属性发生变化时不。)