UWP: Updating UI through data binding from a background thread

后端 未结 1 1739
野性不改
野性不改 2020-12-07 05:22

I\'m using x:Bind (compiled binding) in my UWP app to bind a TextBlock to an integer property in the ViewModel which is converted to a string by a value converter. I am usin

相关标签:
1条回答
  • 2020-12-07 06:16

    You need to execute all graphical objects in the UI Thread.

    • First solution, using MVVM Light framework.

      see Simple example of DispatcherHelper

    • Second solution, using ISynchronizeInvoke.

    Typical usage:

    obj.Invoke((MethodInvoker) SomeMethod);
    

    See How to Use ISynchronizeInvoke interface?

    0 讨论(0)
提交回复
热议问题