Using MS ReportViewer in WPF

前端 未结 3 732
野性不改
野性不改 2020-12-01 05:31

I\'m about to start using the MS ReportViewer in a WPF application by placing the ReportViewer in a WindowsFormsHost.

Is this the correct approach? What is the best

相关标签:
3条回答
  • 2020-12-01 05:53

    Yes, that works, I am using the WindowsFormsHost in a wpf project to wrap the ReportViewer.

    In the ViewModel I am creating the WindowsFormsHost and the ReportViewer:

    WindowsFormsHost windowsFormsHost = new WindowsFormsHost();
    reportViewer = new ReportViewer();
    windowsFormsHost.Child = reportViewer;
    this.Viewer = windowsFormsHost
    

    and in the View I am using a ContentPresenter to display it, by binding to the Property that holds the WindowsFormsHost.

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

    We're using the Business Intelligence Studio (which is an Visual Studio 2008 with templates for editing reports) for report creation. http://msdn.microsoft.com/en-us/library/ms173767.aspx

    Take care,
    Martin

    0 讨论(0)
  • 2020-12-01 06:06

    We've definitely had success just using the WindowsFormsHost. I haven't been involved in creating the RDLC files themselves, but I believe they were designed (as you say) in a WinForms project and then copied across.

    Note that if you don't need local reports you can use a WPF Frame control and point it at the URL of the server-based report (it renders it like a web browser would). This works really well for us too.

    0 讨论(0)
  • 2020-12-01 06:08

    Please note that you can use both WPF-Windows and Windows-Form-Windows in the same application.

    So you can avoid using WindowsFormsHost if you put the ReportViewer in a seperate Windows-Forms-Window that you open from your WPF-Window with ShowDialog.

    Then you can use the ReportViewer also at design time.

    0 讨论(0)
提交回复
热议问题