Reputation: 745
Hi guys,
I'm working on new project that based on Windows Forms C# pattern. One of the window in my software, need to be designed by WPF, is there any way to use WPF window inside Windows Forms project?
I mean, when i'm calling to new window i use this code:
Windows w = new Windows();
w.Show();
but when i'm trying to it on the WPF class it's throwing me an error that it's not supported.
Can i do something like that with the WPF window?
Upvotes: 2
Views: 842
Reputation: 18290
If you find yourself in need to open a WPF Window from a WinForms program:
code snippet:
WPFWindow.Window1 wpfwindow = new WPFWindow.Window1();
ElementHost.EnableModelessKeyboardInterop(wpfwindow);
wpfwindow.Show();
However ensure you have the following using statements:
using System; //Given
using System.Windows.Forms; //Given
using System.Windows.Forms.Integration; //Not so Given.
Refer:
How to programmatically create a WPF window in a WinForm application
Open a WPF Window from WinForms & link form app with WPF app
How to add a WPF window to a WinForms App
Upvotes: 5