wpfuser-controls

Updating a element in WPF user control


I am having a user control and which has some elements along with a ellipse. When my main window in invoked and my user control is created i have a task that loops and does some task. During the execution of this task i need to update a element in the user control. I tried with the below code but it does not updates.

this.Dispatcher.Invoke((Action)(() =>
{

    ellipseRed.Visibility = System.Windows.Visibility.Visible;

}));

Solution

  • Try using:

    Application.Current.Dispatcher
    

    This way you can update UI elements indirectly from another thread.