How do I update a Label from within a BackgroundWorker thread?

后端 未结 5 1945
慢半拍i
慢半拍i 2020-12-20 06:59

When I used WinForms, I would have done this in my bg_DoWork method:

status.Invoke(new Action(() => { status.Content = e.ToString(); }));
sta         


        
5条回答
  •  长情又很酷
    2020-12-20 07:15

    You really should think about using the power of "Data Binding" in WPF.

    You should be updating an object in your view model and binding that to your user interface control.

    See MVVM Light. Simple and easy to use. Don't code WPF without it.

提交回复
热议问题