By using this site you agree to the use of cookies for analytics and personalized content.
I agree Learn More
Stimulsoft Reports.WinRT FAQ
 
1. How to show report?
2. How to save report from code?
1. How to show report?

Add the following code to display the rendered report (*.mdc, *.mdz, *.mdx):

XAML

<Page x:Class="Demo.RT.BlankPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:viewerRT="using:Stimulsoft.Report.Viewer.RT">

    <viewerRT:StiViewerControl x:Name="viewerControl"/>
</Page>

C#

namespace Demo.RT
{
    public sealed partial class BlankPage : Page
    {
        #region Handlers
        async private void BlankPage_Loaded(object sender, RoutedEventArgs e)
        {
            StorageFolder folder = Windows.Storage.KnownFolders.DocumentsLibrary;
            StorageFile storageFile = await folder.GetFileAsync("SimpleList.mdc");

            StiReport report = new StiReport();
            await report.LoadDocumentAsync(storageFile);
            viewerControl.Report = report;
        }
        #endregion

        public BlankPage()
        {
            this.InitializeComponent();
            this.Loaded += BlankPage_Loaded;
        }
    }
}

If the report has not been rendered, i.e. the report template is saved (*.mrt, *.mrz, *.mrx), then enter the following code:

XAML

<Page x:Class="Demo.RT.BlankPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:viewerRT="using:Stimulsoft.Report.Viewer.RT">

    <viewerRT:StiViewerControl x:Name="viewerControl"/>
</Page>

C#

namespace Demo.RT
{
    public sealed partial class BlankPage : Page
    {
        #region Handlers
        async private void BlankPage_Loaded(object sender, RoutedEventArgs e)
        {
            StorageFolder folder = Windows.Storage.KnownFolders.DocumentsLibrary;
            StorageFile storageFile = await folder.GetFileAsync("SimpleList.mrt");

            StiReport report = new StiReport();
            await report.LoadAsync(storageFile);
            await report.RenderAsync();

            viewerControl.Report = report;
        }
        #endregion

        public BlankPage()
        {
            this.InitializeComponent();
            this.Loaded += BlankPage_Loaded;
        }
    }
}
2. How to save report from code?

The report can be saved from the project code. Here is an example of the code to save a report:

XAML

<Page x:Class="Demo.RT.BlankPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:viewerRT="using:Stimulsoft.Report.Viewer.RT">

    <viewerRT:StiViewerControl x:Name="viewerControl"/>
</Page>

C#

namespace Demo.RT
{
    public sealed partial class BlankPage : Page
    {
        #region Handlers
        async private void buttonSaveReport_Click(object sender, RoutedEventArgs e)
        {
            StiReport report = new StiReport();
            StorageFolder folder = Windows.Storage.KnownFolders.DocumentsLibrary;
            StorageFile storageFile = await folder.CreateFileAsync("Report1.mdc");

            await report.SaveDocumentAsync(storageFile);
        }
        #endregion

        public BlankPage()
        {
            this.InitializeComponent();
            this.Loaded += BlankPage_Loaded;
        }
    }
}
TwitterTwitterFacebookFacebookRSSRSSLinked inLinked inYoutubeYoutubeStimulsoft BlogStimulsoft BlogViberViberWhatsAppWhatsAppSkypeSkypeTelegramTelegram