In WPF, is it necessary to re-ToNotifyCollectionChanged after re-assigning an ObservableList?
CodingOctocat opened this issue · 1 comments
CodingOctocat commented
// WPF simple sample.
ObservableList<int> list;
public ISynchronizedView<int, int> ItemsView { get; set; }
public MainWindow()
{
InitializeComponent();
this.DataContext = this;
list = new ObservableList<int>();
ItemsView = list.CreateView(x => x).ToNotifyCollectionChanged();
BindingOperations.EnableCollectionSynchronization(ItemsView, new object()); // for ui synchronization safety of viewmodel
}
protected override void OnClosed(EventArgs e)
{
ItemsView.Dispose();
}
private void DoStuff()
{
list = GetData();
// 👇??? Should I always Clear the list and then AddRange the data?
ItemsView = list.CreateView(x => x).ToNotifyCollectionChanged();
BindingOperations.EnableCollectionSynchronization(ItemsView, new object()); // for ui synchronization safety of viewmodel
}