RDLC报告未显示在用户控件内

时间:2015-12-26 18:19:43

标签: c# wpf xaml user-controls rdlc

我试图在用户控件中显示rdlc报告。问题是我在运行项目时没有显示。

在运行项目之前,我可以在xaml designer中看到它。

Before Running Project in xaml Desginer

运行项目后: enter image description here

这是我的代码:

报告用户控制:

<UserControl x:Class="CPOSApplication.UserControls.Reports.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" Background="#FFFFFFFF"
         xmlns:repview="clr-namespace:Microsoft.Reporting.WinForms;assembly=Microsoft.ReportViewer.WinForms">
<Grid>
    <WindowsFormsHost x:Name="winform" Background="White" Visibility="Visible">
        <repview:ReportViewer  BackColor="white"  x:Name="salesReportViewer"/>
    </WindowsFormsHost>
</Grid>

正在使用它的另一个UserControl:

<UserControl x:Class="CPOSApplication.UserControls.Reports.SalesReport"
         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"
         xmlns:uc="clr-namespace:CPOSApplication.UserControls.Reports"
         mc:Ignorable="d" 
         d:DesignHeight="800" d:DesignWidth="900">
<Grid Style="{DynamicResource GridsCustomStyle}" x:Name="SearchShelfGri">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition MinWidth="100" />
    </Grid.ColumnDefinitions>
    <Border  Grid.ColumnSpan="2" Style="{DynamicResource SearchGridHeaderBorder}">
        <DockPanel Grid.Row="0">
            <Label x:Name="GridLabel" Style="{DynamicResource HeadingLabelsCustomStyle}" Content="Sales Report-:"/>
        </DockPanel>
    </Border>
    <uc:ReportViewer x:Name="salesReport"  Grid.Column="0" Background="White" Grid.Row="1" Margin="0,0"/>
    <uc:FilterSalesReport x:Name="filterShelf"  Grid.Column="1" Grid.Row="1" Background="AliceBlue" Width="300" Padding="2,0,0,0" Margin="0,0"/>
</Grid>

这是.cs文件

public partial class SalesReport : UserControl
{
    public SalesReport()
    {
        InitializeComponent();
        salesReport.salesReportViewer.ProcessingMode = ProcessingMode.Local;
        salesReport.salesReportViewer.LocalReport.ReportPath = @"C:\Users\Safi\Documents\Visual Studio 2012\Projects\CPOS\CPOS\CPOSApplication\Reports\QuarterSaleInvoiceReport.rdlc";
        salesReport.salesReportViewer.RefreshReport();
        salesReport.salesReportViewer.LocalReport.ReportEmbeddedResource = "CPOSApplication.Reports." + ReportType.QuarterSaleInvoice.ToString() + "Report.rdlc";
        salesReport.salesReportViewer.RefreshReport();

    }
}

0 个答案:

没有答案