locked
Using WPF Controls in Winforms RRS feed

  • Question

  • Hi

    In our Winforms project, we are using WPF controls using ElementHost and WPF assemblies.
    Q1.Could any one mention me what care needs to be taken while using WPF controls in Winforms?
    Q2.Would it(using  WPF Controls in Winforms) demand any further requirement or pose any situation during deployment.
    Will there be any performance issues due to interoperability between WPF and Winforms?

    Thank You
    Tuesday, August 10, 2010 5:02 AM

Answers

  • Hi Nagiahrajamma,

    To compile Windows Forms code with WPF added, you’ll need to add the WPF assemblies to your project, including at lease WindowsBase, PresentationCore, and PresentationFramework. Also, because you’re integrating Windows Forms and WPF as before, you’ll need to add a reference to the WindowsFormsIntegration assembly.

    And as useful as WPF’s integration with other presentation technologies is, because WPF’s approach to rendering and composition is radically different from the way Win32 UIs have previously worked, there are some limitation to how you can mix the two. Essentially, the new feature that WPF offers do not translate back into the old world.

    The most important thing to understand is the principle of airsoace: within any single two-level window, each pixel belongs to exactly one technology. So, a single pixel must belong either to WPF or to Win32.

    For more information about Airspace, please refer the link as follows:
    http://msdn.microsoft.com/en-us/library/aa970688.aspx

    For the deployment, I think there's no more work need to be done caused by interop.

    Hope this helps.

    Best regards,
    Kevin Pan


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Kevin Pan Wednesday, August 18, 2010 2:27 AM
    Thursday, August 12, 2010 9:14 AM

All replies

  • Hi Nagiahrajamma,

    To compile Windows Forms code with WPF added, you’ll need to add the WPF assemblies to your project, including at lease WindowsBase, PresentationCore, and PresentationFramework. Also, because you’re integrating Windows Forms and WPF as before, you’ll need to add a reference to the WindowsFormsIntegration assembly.

    And as useful as WPF’s integration with other presentation technologies is, because WPF’s approach to rendering and composition is radically different from the way Win32 UIs have previously worked, there are some limitation to how you can mix the two. Essentially, the new feature that WPF offers do not translate back into the old world.

    The most important thing to understand is the principle of airsoace: within any single two-level window, each pixel belongs to exactly one technology. So, a single pixel must belong either to WPF or to Win32.

    For more information about Airspace, please refer the link as follows:
    http://msdn.microsoft.com/en-us/library/aa970688.aspx

    For the deployment, I think there's no more work need to be done caused by interop.

    Hope this helps.

    Best regards,
    Kevin Pan


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Kevin Pan Wednesday, August 18, 2010 2:27 AM
    Thursday, August 12, 2010 9:14 AM
  • One more comment I have to add, as I stepped on this myself.

    You don't have a WPF application object available.
    So you don't have application wide resources, every control needs to merge the needed resource dictionary into it's own resource dictionary.
    And you cannot use everything else this object provides.

    Thursday, August 12, 2010 9:37 AM