asynchronous UI update from ViewModel in WPF

后端 未结 2 666
忘掉有多难
忘掉有多难 2021-01-03 02:27

I am having a problem with getting data from db and showing in UI asynchronously. I am using MVVM light, when I click the button, action is triggered in ViewModel:



        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-03 02:52

    You haven't shown any of the code that's actually running on the background thread on completion but I'm guessing that in it you're creating a collection object that you're then trying to assign to your CollectionView. When the CV tries to update (on the UI thread) from your Refresh call it would then try to use the collection that's owned by the other thread.

    If you include the relevant code it would be easier to say for sure.

提交回复
热议问题