Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在WPF中使用MS ReportViewer_Wpf_Reportviewer - Fatal编程技术网

在WPF中使用MS ReportViewer

在WPF中使用MS ReportViewer,wpf,reportviewer,Wpf,Reportviewer,我即将开始在WPF应用程序中使用MS ReportViewer,方法是将ReportViewer放置在WindowsFormsHost中 <ContentPresenter Content="{Binding Viewer}" ... 这是正确的方法吗?由于在WindowsFormsHost中无法在设计时使用ReportViewer,因此设计报表的最佳方法是什么 <ContentPresenter Content="{Binding Viewer}" ... 最好在SQL S

我即将开始在WPF应用程序中使用MS ReportViewer,方法是将ReportViewer放置在WindowsFormsHost中

 <ContentPresenter Content="{Binding Viewer}" ...
这是正确的方法吗?由于在WindowsFormsHost中无法在设计时使用ReportViewer,因此设计报表的最佳方法是什么

 <ContentPresenter Content="{Binding Viewer}" ...
最好在SQL Server中创建RDL报告,然后将其转换为RDLC,或者创建新的Winforms应用程序,在Winforms框架中创建RDLC文件,然后将其复制到WPF应用程序


<>我需要通过DoPrdScript过滤报告,所以也需要考虑这个方面。如果有人已经在WPF中使用ReportViewer,我将非常感谢对最佳方法的反馈……非常感谢

仅使用WindowsFormsHost,我们就取得了成功。我没有参与创建RDLC文件本身,但我相信它们是在WinForms项目中设计的(如您所说),然后在整个项目中复制的


请注意,如果不需要本地报表,可以使用WPF框架控件,并将其指向基于服务器的报表的URL(它会像web浏览器一样呈现)。这对我们来说也非常有效。

是的,很有效,我正在wpf项目中使用WindowsFormsHost来包装ReportViewer

在ViewModel中,我正在创建WindowsFormsHost和ReportViewer:

WindowsFormsHost windowsFormsHost = new WindowsFormsHost();
reportViewer = new ReportViewer();
windowsFormsHost.Child = reportViewer;
this.Viewer = windowsFormsHost
在视图中,我使用ContentPresenter通过绑定到保存WindowsFormsHost的属性来显示它

 <ContentPresenter Content="{Binding Viewer}" ...

请注意,您可以在同一应用程序中同时使用WPF窗口和Windows窗体窗口

因此,如果将ReportViewer放在单独的Windows窗体窗口中,并使用ShowDialog从WPF窗口打开,则可以避免使用WindowsFormsHost


然后,您也可以在设计时使用ReportViewer。

感谢您的反馈,Matt,很高兴知道我正朝着正确的方向前进。它工作得很好,但请记住,您不能在xaml窗口标记中添加属性allowTransparency=“True”。如果你说的是真的,WindowsFormsHost就会消失。我必须为WindowsFormsHost定义一个高度,否则,我就看不到reportViewer。