你好,目前当我点击“商业列表”按钮时,它会显示出适当信息的报告窗口。我想让它在我的ShellView中显示,而不是弹出一个“窗口”。
旧代码
PreviewForm.xaml
<Window .......
<Grid>
<WindowsFormsHost Name="MyHost" Margin="0,0,0,0" Visibility="Visible">
<rv:ReportViewer x:Name="_reportViewer" ForeColor="AliceBlue" Visible="True" Dock="Fill"/>
</WindowsFormsHost>
</Grid>
</Window>
PreviewForm.xaml.cs
public string reportSource { get; set; }
public Microsoft.Reporting.WinForms.ReportDataSource reportDataSource { get; set; }
private void Window_Loaded(object sender, RoutedEventArgs e)
{
try
{
this._reportViewer.Reset();
this._reportViewer.LocalReport.ReportEmbeddedResource = this.reportSource;
this._reportViewer.LocalReport.DataSources.Clear();
this._reportViewer.LocalReport.DataSources.Add(this.reportDataSource);
this._reportViewer.LocalReport.Refresh();
this._reportViewer.RefreshReport();
}
catch (Exception Ex)
{
Ex.ToString();
}
}
报告视图模型
public void BusinessListing()
{
try
{
BindableCollection<BusinessDTO> Firms;
using (var ctx = DB.Get())
{
Firms = new BindableCollection<BusinessDTO>(BusinessDTO.ReportBusiness(ctx));
}
Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
reportDataSource1.Name = "BusinessDTO";
reportDataSource1.Value = Firms;
Reports.ReportPreviewForm preview = new Reports.ReportPreviewForm();
preview.reportDataSource = reportDataSource1;
preview.reportSource = "Reports.ListingReports.BusinessListingReport.rdlc";
preview.Show();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
报告网格视图
<shell:GridScreenControl.Grid>
<Grid >
<panes:ReportPreviewForm/>
<Grid >
</shell:GridScreenControl.Grid>
新增内容。
我将 PreviewForm 转换为 UserControl。
更改 Window_Loaded
=>
public void Update()
在我的 ReportViewModel 中,我使用 preview.Update()
而不是 preview.Show()
。但目前只显示一个空白的白屏。
Prism
还是仅通过DataTemplate
更改视图? - StepUp