I doing some WPF application and today i faced some troubles. I need to show splash screen while initializing MainWindow. My code is below:
public MainWindowView()
{
OnLoad();
}
public void OnLoad()
{
worker = new BackgroundWorker();
lw = new WaitWindowView();
lw.Show();
worker.DoWork += delegate(object s, DoWorkEventArgs args)
{
Dispatcher.Invoke(new Action(delegate()
{
InitializeComponent();
DataContext = new NavBarVM();
}), DispatcherPriority.Background);
};
worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
{
lw.Close();
};
worker.RunWorkerAsync();
}
Above code is working. But splash screes is lagging.