views:

653

answers:

1

Hi

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

A: 

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>
Samuel Jack
Hi thanks for the feed back. I just tried the code above and I'm still getting the same errorI was wondering if it is an issue with the Page tag as anywhere I have seen this implemented the window tag is the opening node
Colmdoc
Having Page as root rather than Window shouldn't be a problem. Are you sure this is a build error, and not an error reported by the XAML designer. You could try turning off the XAML designer: right click a XAML file, select Open With, select XML Editor then Set as Default. Restart visual studio to make sure the XAML designer isn't loaded, then try building your project.
Samuel Jack
Hi Samuel Unfortunately it is a build error I have turned off the XAML designer as per your previous suggestion and I am getting the error"The tag 'WindowsFormsHost' does not exist in XML namspace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation', Line 6 Position 8."Thanks for the help with this. I really don't knw what is gone wrong with it.RegardsColm
Colmdoc
Resolved this error I had to remove all my references and add them all back in again which eventually removed the error. I don't know why it was showing up as a build error but its working now. I probably didn't have the correct reference in the first instancethanks for the feedback
Colmdoc