Unknown
Unknown

Reputation: 73

How to navigate to a frame from different thread?

I have to navigate to a page which belongs to the main window from a different thread. I created a separate thread to listen to command line arguments of another process. When I receive "about" from that process through IPC in the thread, I need to open about.xaml from the thread. How can I do it?

This is how I open the page from main window:

_mainFrame.Source = new System.Uri("AboutPage.xaml", UriKind.Relative); 

How can I do the same from different thread ?

Upvotes: 1

Views: 550

Answers (1)

Chris
Chris

Reputation: 925

you can use the dispatcher to send actions to the UI thread.

Dispatcher.CurrentDispatcher.Invoke(()=>
{
        _mainFrame.Source = new System.Uri("AboutPage.xaml", UriKind.Relative); 
});

Upvotes: 2

Related Questions