Im trying to load a xml file into a dataset and generate crystal report with loaded data.
im using Crystal Reports WPF Application for the project.
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
reportViewer.Owner = this;
DataSet dset = new DataSet1();
DataSet reportData = new DataSet();
reportData.ReadXml("http://192.168.1.10/test/persons.xml");
dset.Tables[0].Merge(reportData.Tables[0]);
ReportDocument report = null;
report = new CrystalReport1();
report.SetDataSource(dset.Tables[0]);
reportViewer.ViewerCore.ReportSource = report;
}
}
This working fine and my question is how to move download xml and set report codes to a different event to load report after the application is shown?
Regards
Here is the Window Lifetime Management events: (MSDN)
I believe
Activatedevent is what you need. Considering thatActivatedevent fires not only when a window opened first time but also when ALT+TAB switches and so on so to filter out first windo opening from other Activated events just use boolean flag setting it to true when first timeActivatedevent was handled: