我正在尝试在WPF应用程序中查看rdlc报表,我已经使用WindowsFormHost托管rdlc报表查看器,但是当我运行该应用程序时,没有任何错误,但也注意到在报表查看器中甚至没有显示报表查看器正在显示。这是xaml代码
<WindowsFormsHost Name="windowsFormsHost" Grid.Row="2" >
<rv:ReportViewer x:Name="reportViewer"/>
</WindowsFormsHost>
以及用于报告加载的C#代码
List<Furniture> Purchases = null;
using (IDbConnection db = new SQLiteConnection(ConfigurationManager.ConnectionStrings["cs"].ConnectionString))
{
if (db.State == ConnectionState.Closed)
{
db.Open();
}
string Command = "Select I.Id,I.Title,I.Category,I.Description,I.VoucherNumber,I.Cost,I.PurchasedDate,B.Title AS BudgetHead,D.Name AS Distributer, F.Type,F.Color,F.Condition,I.Status,I.CreatedBy FROM Items I INNER JOIN Furniture F ON I.Id=F.EntryId INNER JOIN BudgetHeads B ON I.BudgetHeadId=B.Id INNER JOIN Distributers D ON I.DistributerId=D.Id";
Purchases = db.Query<Furniture>(Command,null, commandType: CommandType.Text).ToList();
}
reportViewer.LocalReport.DataSources.Clear();
var DataSource = new ReportDataSource() { Name = "FurnitureDataSource", Value = Purchases };
reportViewer.LocalReport.DataSources.Add(DataSource);
string Path = @"D:\ADiTM\Products\Stock Management\Software\Reports\Purchase.rdlc";
reportViewer.LocalReport.ReportPath = Path;
reportViewer.Dock = DockStyle.Fill;
reportViewer.Refresh();
reportViewer.RefreshReport();
我得到了解决方案,实际上在主窗口中将allow透明度设置为true,这导致Windows主机在运行时不显示任何内容。