Link to home
Start Free TrialLog in
Avatar of jjliu4492
jjliu4492

asked on

WPF ReportViewer user control

I have a windows application that uses WPF, and currently it displays reports using SSRS. When a user clicks on a report link, it opens the report in a new IE window. What I would like it to do is when the user clicks on a report link, have it display the report within the windows application itself. I want to leverage the ReportViewer, by creating a user control, so that I can implement the control on any page I want within my application. How would I do this? Attached is the user control that I have created, but I am not sure where to go from here.
<UserControl x:Class="HCB.VS2010.ABISS3.UI.FormsAndControls.UserControls.ReportViewer"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
            
    </Grid>
</UserControl>

Open in new window

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace HCB.VS2010.ABISS3.UI.FormsAndControls.UserControls
{
    /// <summary>
    /// Interaction logic for ReportViewer.xaml
    /// </summary>
    public partial class ReportViewer : UserControl
    {
        public ReportViewer()
        {
            InitializeComponent();
        }
    }
}

Open in new window

Avatar of Gewgala
Gewgala
Flag of United States of America image

Question: Is your report viewer an actual web page?  The part with the links that the user clicks?

Depending on the answer to my question above you may be able to leverage a WebBrowser control within your WPF application if the ReportViewer forces the results to be displayed within a browser.  

You would need to post a little more information about your report viewer and also, this is a WPF Desktop application right?  Not xbap?
Avatar of jjliu4492
jjliu4492

ASKER

Yes this is a WPF Desktop application.

I would like my report viewer to be a user control within the page that has the report link that the user clicks. So for example, when the user clicks on the Inventory Report link, the report viewer control will be populated within that same page.
Ok and your report viewer, under normal circumstances that is embedded into a web page right?
Yes, how it works now is when a report link is clicked, the report opens in a new IE web page window.
Ok, now where the report links are, is that also in a web page?  What generates the links to click?
The links are buttons on the top of the page on the windows application. Please see screenshot attachments. The attachment called DesktopApplication is the application where the report links are located, they are located on the top right of the screen. When you click the "Inventory Details" link, the report opens in a new IE window.  User generated imageReportWindow.png
Ok.  What is the code that is executed when you click on one of those links?

Because, it seems like what is happening is when clicking the link it's trying to navigate to a specific URL.  If you know what that URL is, you could add a WebBrowser control to your WPF window, and then do something like this:

webBrowser1.NavigateToUrl("theUrlTheReportViewerIsTryingToLoad");

have you tried that?
Will the NavigateToURL open the report in the existing window, or in a new window?
It will open it in the WebBrowser control that is in your WPF Form.  You can drag it from the toolkit onto your window in the Visual Studio Designer.
error message: "System.Windows.Controls.WebBrowser does not contain a definition for 'NavigateToURL'..."
ASKER CERTIFIED SOLUTION
Avatar of Gewgala
Gewgala
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It's working, thanks a ton!
Glad I could help :)