4

I am adding a WINFORM chart to my WPF project using

 System.Windows.Forms.Integration.WindowsFormsHost

I am trying to work around the "airspace" rendering issue where the host is always rendered as the top most element the window. The workaround I am using sets

IsRedireced = "true"

When I insert this into my XMAL code:

        <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>

or my code behind:

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

host.IsRedirected = "true";

I get the following error:

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

Here is a screenshot:

error

Can anyone help explain why this is happening? I relay need to display an element on top of my WINFORM chart!

Thanks

EDIT:

Code was taken from MSDN site: 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"

"Copy the following XAML into the Grid element."

<!-- 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.

"To see the z-order behavior when IsRedirected is true"

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.
Mahesh Waghmare
  • 726
  • 9
  • 27
Hooplator15
  • 1,540
  • 7
  • 31
  • 58
  • Look on [msdn](http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.windowsformshost(v=vs.110).aspx), "IsRedirected" is not a property of the WFH. If you're using someone else's code, you're going to have to link to it. – Alex Jul 23 '14 at 15:35
  • My code was pulled straight from the MSDN site: http://msdn.microsoft.com/en-us/library/ms752027.aspx Look under "Understanding z-order limitations." – Hooplator15 Jul 23 '14 at 15:36
  • 2
    http://bartwullems.blogspot.com/2012/11/wpf-45-airspace-problem-solved.html Looks like it was a beta feature that was removed. The MSDN page should be updated. – Alex Jul 23 '14 at 15:52
  • Wow... well is there any other way to overlay a wpf element over my hosted chart? – Hooplator15 Jul 23 '14 at 15:57
  • 1
    Not my area of expertise, but the comments there suggested 'no'. Have you considered a different charting tool? I've had moderate success with OxyPlot. – Alex Jul 23 '14 at 15:58
  • I took a look at OxyPlot and it looks like a good tool. I am going to try it out. (I'm assuming it is free?) Thanks! It's a shame that such a good Beta feature was removed! – Hooplator15 Jul 23 '14 at 16:07

2 Answers2

3

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.

(emphasis added)

Glenn Slayden
  • 17,543
  • 3
  • 114
  • 108
0

Which .Net Framework are you using here. IsRedirected for WindowsFormHost is released with Framework 4.5

  • 3
    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. – komizo Nov 07 '14 at 13:29