Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
483 views
in Technique[技术] by (71.8m points)

Using MS ReportViewer in WPF

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 way of designing the reports as you cannot use the ReportViewer at design time in a WindowsFormsHost.

Is it best to create an RDL report in SQL Server and then convert it to an RDLC or maybe to create a new Winforms app to create an RDLC file in a WinForms framework and then copy it to the WPF app.

I will need to filter the reports via dropdowns so there's that aspect to consider too. If anyone out there is already using ReportViewer in WPF I would appreciate some feedback on the best approach.....Many thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...