WindowsFormsHost is always the most top from WPF element

后端 未结 4 1600
长发绾君心
长发绾君心 2020-12-01 17:11

how to set the z-index windowsformhost that they are not always at the top of the WPF element ?

4条回答
  •  孤街浪徒
    2020-12-01 17:16

    Update, a few years later (2016-09):

    My following answer, as noted by the top comment, is no longer valid, and was not available in the final version of .NET 4.5, or subsequent releases. Unfortunately, the link I included still has z-ordering information for HwndHosts present for the "current version" of .NET, which could lead some to believe this functionality does, in fact, exist. It doesn't. There is no work-around.

    Original answer:

    A year later, things have changed a bit with .NET 4.5. For those who stumbled upon this, much as I did, here is a more updated excerpt from Walkthrough: Arranging Windows Forms Controls in WPF on MSDN:

    By default, visible WindowsFormsHost elements are always drawn on top of other WPF elements, and they are unaffected by z-order. To enable z-ordering, set the IsRedirected property of the WindowsFormsHost to true and the CompositionMode property to Full or OutputOnly.

    All you need to do, when using .NET 4.5, is add the following attributes to your WindowsFormsHost element IsRedirected="True" and CompositionMode="Full" or CompositionMode="OutputOnly".

提交回复
热议问题