Home > Back-end >  Making a popup window/toastbox when wpf application starts
Making a popup window/toastbox when wpf application starts

Time:11-25

im very new to WPF, ive been working in winforms a bit before now, in visual studio. im making an application for my company that is to be designed for use by the end user.

i need to find out what object i need as a splash screen type thing, but i plan on having a button or something in there, so a popup window might work? not sure

what i do really need to know is how to initiate an object like a popup window on startup of the application, thanks:)

CodePudding user response:

Quite difficult to understand you question, however if you want a custom Splash screen, it can easily be done by adding the code to the App.xaml.cs by overriding OnStartup method. Hope that will help you

Example:

 protected override void OnStartup(StartupEventArgs e)
        {
            //Create a windows instance - Ideally you should create a custom window xaml and create instance of it
            var splashscreenwindows = new Window();
            //This will ensure that the SplashWindows will be shown above all other windows
            splashscreenwindows.Topmost = true;
            //Display a windows
            splashscreenwindows.Show();
            //Set a timer. This is needed for cases, when the machine is too fast, in order to insure that splashscreen will be shown
            Thread.Sleep(1000);
            //Do you initializing work here
            
            //Close the Splashscreen
            splashscreenwindows.Close();

            //Continue with the default behavior
            base.OnStartup(e);
}
  • Related