Is there a Threadsafe Observable collection in .NET 4?

前端 未结 4 1761
南方客
南方客 2020-12-03 01:45

Platform: WPF, .NET 4.0, C# 4.0

Problem: In the Mainwindow.xaml i have a ListBox bound to a Customer collection which is currently an ObservableCollecti

4条回答
  •  悲&欢浪女
    2020-12-03 01:47

    There's a detailed explanation and an implementation here. It was written mainly for .NET 3.5 SP1 but it will still work in 4.0.

    The primary target of this implementation is when the "real" list exists longer than the bindable view of it (eg. if it is bound in a window that the user can open and close). If the lifetimes are the other way around (eg. you're updating the list from a background worker that runs only when the window is open), then there are some simpler designs available.

提交回复
热议问题