gpt4 book ai didi

c# - WindowsFormsHost 错误 IsRedirected 未找到?

转载 作者:行者123 更新时间:2023-11-30 16:58:43 26 4
gpt4 key购买 nike

我正在使用以下方法将 WINFORM 图表添加到我的 WPF 项目中

 System.Windows.Forms.Integration.WindowsFormsHost

我正在尝试解决“领空”呈现问题,其中主机始终呈现为窗口的最顶部元素。我正在使用的解决方法 sets

IsRedireced = "true"

当我将其插入我的 XMAL 代码时:

        <Grid x:Name="ssCurveChartGrid" Grid.Column="1" Margin="110,30,160,306" Grid.ColumnSpan="4" RenderTransformOrigin="0.479,0.186">
<WindowsFormsHost IsRedirected =" "true">

</WindowsFormsHost>
</Grid>

或者我后面的代码:

System.Windows.Forms.Integration.WindowsFormsHost host =
new System.Windows.Forms.Integration.WindowsFormsHost();

host.IsRedirected = "true";

我收到以下错误:

The property 'IsRedirected' was not found in type 'WindowsFormsHost'

截图如下:

error

谁能帮忙解释一下为什么会这样?我需要在我的 WINFORM 图表顶部显示一个元素!

谢谢

编辑:

代码取自 MSDN 站点:http://msdn.microsoft.com/en-us/library/ms752027.aspx

From 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. To see the default z-order behavior"

“将以下 XAML 复制到 Grid 元素中。”

<!-- Z-order demonstration. -->
<Canvas Grid.Row="1" Grid.Column="1">
<WindowsFormsHost Canvas.Top="20" Canvas.Left="20" Background="Yellow">
<wf:Button Text="Windows Forms control" FlatStyle="Flat"/>
</WindowsFormsHost>
<Label Content="A WPF label" FontSize="24"/>
</Canvas>

Press F5 to build and run the application. The WindowsFormsHost element is painted over the label element.

“查看 IsRedirected 为真时的 z 顺序行为”

Replace the previous z-order example with the following XAML.
XAML

<!-- Z-order demonstration. -->
<Canvas Grid.Row="1" Grid.Column="1">
<WindowsFormsHost IsRedirected="True" CompositionMode="Full" Canvas.Top="20" Canvas.Left="20" Background="Yellow">
<wf:Button Text="Windows Forms control" FlatStyle="Flat"/>
</WindowsFormsHost>
<Label Content="A WPF label" FontSize="24"/>
</Canvas>

Press F5 to build and run the application. The label element is painted over the WindowsFormsHost element.

最佳答案

Microsoft .NET Framework 4.5 Beta Readme

1.3.10 Windows Presentation Foundation (WPF)

1.3.10.1 HwndHost feature has been removed from WPF in the .NET Framework 4.5 Beta

The .NET Framework 4.5 Developer Preview included a WPF HwndHost redirection feature. However, this feature had several known issues and has been removed from the .NET Framework 4.5 Beta. It will not be included in any future releases.

To resolve this issue:

No workaround is available.

(强调)

关于c# - WindowsFormsHost 错误 IsRedirected 未找到?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24914703/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com