WPF ListBox Binding Update

谁说我不能喝 提交于 2019-12-01 12:48:57

For your case best way use mvvm patern. In brief: Your model OrderItem should implement interface INotifyPropertyChanged. If property changed, it notified about this. Then create viewmodel and set it in datacontext. In viewModel add ObservableCollection with OrderItems, this collection should notified view about changes in it. for more information read some articles like this: MVVM

Instead of using a List<OrderItem> use ObservableCollection<OrderItem>. This will notify that something was added/removed so your ListBox knows to refresh.

Additionally, your OrderItem needs to implement INotifyPropertyChanged and your setters need to call OnPropertyChanged.

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