WPF ReportViewer does not display report

5 posts, 0 answers
  1. Samuel
    Samuel avatar
    16 posts
    Member since:
    Dec 2011

    Posted 10 Jul Link to this post

    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>
  2. Todor
    Admin
    Todor avatar
    145 posts

    Posted 13 Jul Link to this post

    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
  3. Samuel
    Samuel avatar
    16 posts
    Member since:
    Dec 2011

    Posted 13 Jul in reply to Todor Link to this post

    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.
  4. Todor
    Admin
    Todor avatar
    145 posts

    Posted 18 Jul Link to this post

    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
  5. Samuel
    Samuel avatar
    16 posts
    Member since:
    Dec 2011

    Posted 01 Aug in reply to Todor Link to this post

    The example has RadComboBox in it in several places.  This project does not build on my machine as a result.
Back to Top