Reputation: 77
I am new in wpf application.. I am working on window application.it has many module.its one of module is in wpf which is seperate from project.so I want to integrate wpf application into window application project.
Upvotes: 0
Views: 1155
Reputation: 1211
You can use ElementHost to add your wpf controls to windows forms. Add ElementHost control to windows form and set your wpf control as ElementHost Child property.
You can find more details here
MSDN
Upvotes: 0
Reputation: 7352
Assuming you mean MDI Winform for "windows Application". Here are the steps:
These steps only work in .NET Framework 3.0 or above, where WPF is supported.
Upvotes: 2
Reputation: 44096
You need to add an interop layer between the MDI application and the WPF component that you want to host. This is non-trivial.
1) Determine where the border between your managed and native code will lie. Ensure that you clearly define, delineate, and respect this border, or you will weep tears of pain. This will require use of C++/CLI in any real-world scenario.
I suggest creating a C++/CLI ref class called something like "Launcher" to act as a springboard. It exposes a native API that your native application can consume. The native application provides a pointer to your MDI window and any other req'd information.
2) Use the MDI child pointer and an HwndSource on the WPF component to drop your WPF into the native window.
3) Supply appropriate manual forwarding of window messages from MDI-land to WPF-land via a MessageHook in the HwndSource. Note that you'll manually be handling everything from WM_WINDOWPOSCHANGED to ID_HELP.
Good luck!
Upvotes: 0
Reputation: 2866
Your question is unclear. However, if you are trying to host a WPF object inside of a WinForms application, then yes, that is possible.
A good tutorial can be found here.
Upvotes: 5