开发者

Problem Inserting Report Viewer into WPF Application using WindowsformsHost

I am trying to create a popup from my WPF application which shows a report viewer hosted in a WindowsFormsHost however I am having problems with the following Xaml

<Page x:Class="FIS3.ReportViewer.ReportViewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
Title="MapViewer">
<Grid>
    <my:WindowsFormsHost>

    </my:WindowsFormsHost>
    <Label Name="exampleText" Content="this is the Report Viewer ..." />
</Grid>

I am getting a build error notifying me that "The type 'my:WindowsFormsHost' was not found. Verify that you are not missing an assembly reference and 开发者_JAVA百科that all referenced assemblies have been built"

have I made an error in my XAML I have added WindowsFormsIntegration as a reference to my project.

Thanks for your help

Col


There is a second solution to this that people seem to have overlooked. I scratched my head on this one for a good 20 minutes. No solution, including this one, would work. Turns out the solution for me was to add:

WindowsFormsIntegration

to my references

after I realized that based on:

http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.windowsformshost.aspx

that this uses the WindowsFormsIntegration.dll. It seemed to have been missing from my references.

Hope this helps!


According to the MSDN documentation, WindowsFormsHost is included in the default Xaml namespace ("http://schemas.microsoft.com/winfx/2006/xaml/presentation") - though you do need to reference WindowsFormsIntegration, as you have done. Have you tried referencing WindowsFormsHost with no namespace prefix?

<Page x:Class="FIS3.ReportViewer.ReportViewer"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 Title="MapViewer">
 <Grid>
   <WindowsFormsHost>

   <WindowsFormsHost>
  <Label Name="exampleText" Content="this is the Report Viewer ..." />
 </Grid>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜