Click here to Skip to main content
15,912,665 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 2 projects - 1 is a Winforms application and the second is a WPF form (both C# .NET4). I would like to call the WPF form from my winforms application by creating an object of the WPF application class(passing a few values to the constructor as well) and using the .show() method.

I need an example of how to do this as I am new to MVVM pattern and I am not sure how to do this.

name of view = MainWindow.xaml
name of view model viewModel = MyViewModel.cs (the data context of my view is set to my view model)
the model is common to both the winforms and WPF application.
I am not sure what object to create to display the WPF form.

If you can give me any link to a sample application it will be a big plus point.
Posted
Updated 25-Mar-13 2:17am
v2

1 solution

I recently come across sample of creating systry application as systry application and not winform application that minimize to the try. long story short it include the using of winform and wpf in the same program.
this is the article:
https://www.simple-talk.com/dotnet/.net-framework/creating-tray-applications-in-.net-a-practical-guide/[^]
and the exact section:
https://www.simple-talk.com/dotnet/.net-framework/creating-tray-applications-in-.net-a-practical-guide/#fifteenth[^]

He wrote there that he took this from here:
http://weblogs.asp.net/jdanforth/archive/2008/07/29/open-a-wpf-window-from-winforms.aspx[^]

also from there you can go to mixing wpf and winform
https://www.simple-talk.com/dotnet/.net-framework/mixing-wpf-and-winforms/[^]

I hope this will help you.
 
Share this answer
 
Comments
rohith naik 25-Mar-13 10:46am    
Thanks Yair-I, i didnt know about the EnableModelessKeyboardInterop(). Thanks for all the links too.
Maciej Los 25-Mar-13 11:06am    
+5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900