How to create XAML splash screen with PRISM

Topics: Prism v4 - WPF 4
Jul 18, 2012 at 10:52 PM

I am using PRISM 4.1 with UNITY for my application. I want to display a nice splash screen which will be a xaml window that will show a progress bar. Once all modules are loaded (one of the modules does lengthy database access operation on startup) splash screen should clode and shell is shown. I cannot find any sample for this, all samples online use in-built SplashScreen which just points to static image. I want my splash screen to be xaml not just a static image or animated gif.

Jul 19, 2012 at 3:22 PM
Edited Jul 19, 2012 at 3:25 PM

I did it in Prism 4.0 by modifying App.xaml.cs like so:

        private static void RunInDebugMode()
        {
            Thread oThread = new Thread(new ThreadStart(splash));
            oThread.SetApartmentState(ApartmentState.STA);
            oThread.Start();

            MEBootstrapper bootstrapper = new MEBootstrapper();
            bootstrapper.Run();
        }

        private static void RunInReleaseMode()
        {
            AppDomain.CurrentDomain.UnhandledException += AppDomainUnhandledException;
            try
            {
                Thread oThread = new Thread(new ThreadStart(splash));
                oThread.SetApartmentState(ApartmentState.STA);
                oThread.Start();

                MEBootstrapper bootstrapper = new MEBootstrapper();
                bootstrapper.Run();
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }

        public static void splash()
        {
            Splash ss = new Splash();
            ss.ShowDialog();
        }

Where Splash is a XAML window