我正在使用具有自定义ItemsSource的ListBox:
this.ListOfPersonsListBox.ItemsSource = (List<Person>)ListOfPersons.AllPersons;
ListOfPersons是一个静态类,因此它无法实现INotifyPropertyChanged或IObservableCollection。
更新列表后重新绘制ListBox的最简单方法是什么?我的当前代码可以工作,但我想找到更清晰的解决方案:
private void SyncButton_Click(object sender, EventArgs e)
{
ListOfPersons.Sync();
this.ListOfPersonsListBox.ItemsSource = null;
this.ListOfPersonsListBox.ItemsSource = ListOfPersons.AllPersons;
}