I got a WPF project, which is compiled into a dll and will be called from another application. That's how it is set up. In this WPF project I need to pop up a customized message box from the view model of the main window to show messages to the user. This customized message box requires a Window parameter. That's how it is.
For a WPF application, Application.Current.MainWindow
will get me what I need. But here it is a dll, so Application.Current is null, and leads to run time exception.
I also tried something like Window.GetWindow(this)
.
Here it is not working, because 'this' is the view model, so it won't give me the handle of the main window.
What else can I try to get the handle of the main window here?
Thanks.
Reflection
and instansiate it throughActivator.CreateInstance()
– Omri Btian