8

I have a WPF application using MVVM. I have some user controls that show some SSRS reports in a ReportViewer control hosted within a windows forms host control.

The User Control has a simple combobox where the user selects a criteria and therefore the report satisfying this criteria will be loaded, its data fetched from the database and then the report is shown to the user.

What is the best approach to implement such scenario in WPF using MVVM?

2 Answers 2

7

Look at this answer

He is creating the WindowsFormsHost and ReportViewer in the ViewModel

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

and then using a ContentPresenter to display it

<ContentPresenter Content="{Binding Viewer}" /> 
Sign up to request clarification or add additional context in comments.

3 Comments

I am unable to get this.Viewer? What is Viewer here?
Viewer is a property of System.Windows.Forms.Integration.WindowsFormsHost type
I am not able to find that property in WindowsFormsHost
0

Unfortunately, there is no native WPF Report Viewer control with similar functionality and there will not be one in .Net 4.0 (according to Jamie Rodriguez at Microsoft).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.