How do I refresh visual control properties (TextBlock.text) set inside a loop?

前端 未结 5 930
醉梦人生
醉梦人生 2020-12-14 04:08

With each loop iteration, I want to visually update the text of a textblock. My problem is that the WPF window or control does not visually refresh until the loop is complet

5条回答
  •  醉梦人生
    2020-12-14 04:30

    You can do Dispatcher.BeginInvoke in order to do a thread context-switch so that the rendering thread could do its job. However, this is not the right way for such things. You should use Animation + Binding for things like that, as this is the hack-free way of doing things like that in WPF.

提交回复
热议问题