1

I have the problem with data transfer - i have a wpf application with a splash screen which is runs in App class before main frame is loaded. This Splash is a dialog and App is a static class - how is it possible to pass the data from splash dialog to mainframe maybe via App.. or there is other way?

curiousity
  • 4,703
  • 8
  • 39
  • 59

1 Answers1

1

An event could pass the data about.

public App : Application
{
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            var splash = new Splash();
            var main = new Main();

            splash.SplashViewFinished += (s, data) => {
                main.Data = data;

                //code to show main..
            };

            //code to show splash...
        }
}

public class Splash : Window
{
    public event EventHandler<SplashDataArgs> SplashViewFinished;
}

public class SplashDataArgs: EventArgs
{

}

Or you could use the mediator pattern. Like the Messenger class in MVVM light

http://www.galasoft.ch/mvvm/

Handling Dialogs in WPF with MVVM

http://mvvmlight.codeplex.com/discussions/209338?ProjectName=mvvmlight

Community
  • 1
  • 1
Hath
  • 12,606
  • 7
  • 36
  • 38