0

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.

2
  • Huh? A WPF application is already a Windows application. Commented 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 advance Commented Jul 28, 2011 at 18:31

4 Answers 4

5

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.

Sign up to request clarification or add additional context in comments.

Comments

2

Assuming you mean MDI Winform for "windows Application". Here are the steps:

  1. Create a new child Winform.
  2. Add "WPF Interoperability" Element
  3. Add your WPF pages to the WPF interop element

These steps only work in .NET Framework 3.0 or above, where WPF is supported.

Comments

0

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

i want to know only steps.bcoz i was unable to find it in goggle search.
0

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

ElementHost

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.