Multithreading - Opening new WPF window

Asked

Viewed 112 times

0

I was wondering if any of vcs knows how to fix this damn error, (I want to open another window but it gives this error at start time) = can help?

  • If you post the code maybe to give a helping hand but so it gets hard, post the code.

1 answer

0

I don’t use more than 1 window for applications, just use the main window and fill it with Viewmodels-linked usercontrols in the MVVM model, but usually when it comes to using different threadVoce has to use with Dispatcher.Invoke(...)

see my example to change the background color of a message popup (Toast type)

TempBackgroundColor.Dispatcher.Invoke(() => TempBackgroundColor = corfundo);

as mentioned by Anderson Henrique without more information we can not help

a kick in the dark (and without testing anything) I would use something like this:

var w = new Window();
this.Dispatcher.Invoke(() => w.Show());

The this in case it is your MainWindow.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.