Hello, the moment I click on the "Business Listing" button, it displays a window of my report with relevant information. I am trying to show it in my ShellView instead of "windows pop up."
Old code
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();
}
}
ReportViewModel
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);
}
}
ReportGridView
<shell:GridScreenControl.Grid>
<Grid >
<panes:ReportPreviewForm/>
<Grid >
</shell:GridScreenControl.Grid>
Additions.
I converted the PreviewForm to UserControl.
Changed Window_Loaded=>
public void Update()
and in my ReportViewModel instead preview.Show()I have preview.Update()
It currently just shows a blank white screen.
source
share