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.
-
Huh? A WPF application is already a Windows application.BoltClock– BoltClock2011-07-28 18:29:42 +00:00Commented Jul 28, 2011 at 18:29
-
wpf form is in xaml.how could i open it in mdi form.pls tell me syntax .thanks for advanceuser644194– user6441942011-07-28 18:31:07 +00:00Commented Jul 28, 2011 at 18:31
4 Answers
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.
Comments
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!
1 Comment
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