INotifyPropertyChanged in WPF

我的未来我决定 提交于 2019-12-01 19:18:17

The problem is that you are directly setting the original list onto the Window.DataContext, so nothing ever listens to the windows' PropertyChanged event.

To solve this, set the DataContext to the window itself:

this.DataContext = this;

and then change the Binding so refer to the property:

<ComboBox ItemsSource="{Binding MyList}" />

You will also need to change your property definition so that it raises the name of the property being changed, not the name of the member:

this.RaisePropertyChanged("MyList");

I think you have two problems:

1) binding should be: {Binding MyList}

2) on MyList setter you should use RaisePropertyChanged("MyList");

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!