我正在使用
将WPFORM图表添加到我的WPF项目中 System.Windows.Forms.Integration.WindowsFormsHost
我正在尝试围绕空域"渲染问题,主机始终呈现为窗口的最顶层元素。我正在使用的解决方法集
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 http://i57.tinypic.com/2eal2k7.jpg
任何人都可以帮忙解释为什么会这样吗?我继续需要在我的WINFORM图表上显示一个元素!
由于
编辑:
代码来自MSDN网站:http://msdn.microsoft.com/en-us/library/ms752027.aspx
来自MSDN: &#34;默认情况下,可见的WindowsFormsHost元素始终在其他WPF元素之上绘制,并且它们不受z顺序的影响。要启用z-ordering,请将WindowsFormsHost的IsRedirected属性设置为true,将CompositionMode属性设置为Full或OutputOnly。 要查看默认的z顺序行为&#34;
&#34;将以下XAML复制到Grid元素中。&#34;
<!-- 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.
&#34;要查看IsRedirected为真时的z顺序行为&#34;
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.
答案 0 :(得分:2)
Microsoft .NET Framework 4.5 Beta Readme
1.3.10 Windows Presentation Foundation(WPF)
1.3.10.1已从.NET Framework 4.5 Beta中的WPF中删除了HwndHost功能
.NET Framework 4.5 Developer Preview包含WPF HwndHost重定向功能。但是,此功能 有几个已知问题,已从.NET Framework 4.5 Beta中删除。 它将不会包含在任何将来的版本中。
要解决此问题:
没有可用的解决方法。
(强调补充)
答案 1 :(得分:0)
您在这里使用哪个.Net Framework。用于WindowsFormHost的IsRedirected随Framework 4.5一起发布