This is a migrated thread and some comments may be shown as answers.

WPF ReportViewer does not display report

4 Answers 572 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Samuel
Top achievements
Rank 1
Samuel asked on 11 Jul 2018, 03:23 AM

I am using the most-current version of Telerik Reporting.  I am testing with a very simple MVVM solution.  The report only has a report header page with a text block in it.  I have the report viewer in the main window and bound to the reportsource in the viewmodel.  The report will not display.  I have looked at several examples and do this same thing but none work for me.

 

public class MainWindowViewModel
        : ViewModelBase
    {
        private string MessageValue = "Nothing to see here...";
        public string Message
        {
            get => MessageValue;
            set
            {
                MessageValue = value;
                RaisePropertyChanged();
            }
        }
 
        private Telerik.Reporting.ReportSource ReportValue;
 
        public Telerik.Reporting.ReportSource Report
        {
            get => ReportValue;
            set
            {
                ReportValue = value;
                RaisePropertyChanged();
            }
        }
 
 
        public void RunReport()
        {
            Message = "Begin report run...";
 
            Task.Run(() => {
                System.Threading.Thread.Sleep(5000);
 
                App.Current.Dispatcher.BeginInvoke(new Action(() => {
                    var rs = new Telerik.Reporting.InstanceReportSource() { ReportDocument = new Report1() };
                    this.Report = rs;
                    Message = "Report complete.";
                }));
 
            });
 
        }
    }

 

 

<Window x:Class="ReportingTest.MainWindow"
        xmlns:local="clr-namespace:ReportingTest"
        xmlns:telerik="http://schemas.telerik.com/wpf"
        DataContext="{Binding MainWindowViewModel, Source={StaticResource ModelLocator}}"
        mc:Ignorable="d"
        Loaded="Window_Loaded"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries />
        </ResourceDictionary>
    </Window.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
 
        <TextBlock Grid.Row="0"
                   Height="25"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Center"
                   Text="{Binding Message}" />
 
        <telerik:ReportViewer Grid.Row="1"
                              ViewMode="PrintPreview"
                              VerticalAlignment="Stretch"
                              ReportSource="{Binding Report}"
                              HorizontalAlignment="Stretch" />
 
    </Grid>
</Window>

4 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 13 Jul 2018, 02:08 PM
Hello Samuel,

I have attached a sample demonstrating how to use WPF Report Viewer in MVVM scenario. The sample is based on Using the WPF Report Viewer in an MVVM scenario KB article.
To run the application it will be necessary to add manually Telerik.Windows.ControlsTelerik.Windows.Controls.InputTelerik.Windows.Controls.Navigation and Telerik.Windows.Data assemblies to project References. Check also Manual Setup article.

If the problem persists, please, open a support ticket and attach a runnable sample project reproducing the issue for local investigation.

Regards,
Todor
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Samuel
Top achievements
Rank 1
answered on 13 Jul 2018, 04:29 PM
Thanks for the reply.  However, we have a license for Telerik Reporting and do not use the other controls on which your example depends.  And the code I originally posted as not working is virtually the exact same as the project you provided, which, also doesn't work.
0
Todor
Telerik team
answered on 18 Jul 2018, 11:48 AM
Hi Samuel,

I have explained the issues with the project attached in the Support Ticket (ID #1176094) you have opened on the same topic. For the benefit of the rest of the community I will post them briefly also here:

 - The WPF Report Viewer relies on Telerik UI for WPF controls, hence to display the viewer in a Window it is necessary to refer the appropriate assemblies, as explained in the Manual Setup article. The assemblies are distributed with Telerik Reporting and do not require additional subscription for Telerik UI for WPF.
The assemblies can be found in (Telerik Reporting installation folder)\Examples\CSharp\WpfDemo\bin (for example C:\Program Files (x86)\Progress\Telerik Reporting R2 2018\Examples\CSharp\WpfDemo\bin).

 - It is necessary to merge the ResourceDictionaries in the App.xaml file, as explained in the above referred article.

The project attached to my previous message runs correctly on our side. It relies on the same four assemblies, required for the WPF Report Viewer to work, i.e. no additional subscription is required.

Regards,
Todor
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Samuel
Top achievements
Rank 1
answered on 01 Aug 2018, 08:05 PM
The example has RadComboBox in it in several places.  This project does not build on my machine as a result.
Tags
General Discussions
Asked by
Samuel
Top achievements
Rank 1
Answers by
Todor
Telerik team
Samuel
Top achievements
Rank 1
Share this question
or