0
votes

I am developing a WPF application. I am using two monitors. I am using splash screen to pop up on window when some function is executing.

The problem I have is when I move the application to secondary monitor and start processing functions splash screen is still being displayed in primary monitor instead on secondary monitor.

Any help on this?

1
Probably best to post your code.Ben Robinson
Splash screen is not the appropiate solution for this. Use a regular window and set the MainWindow as it's Owner.Federico Berasategui
The question doesn't quite make sense to me. A "splash screen" is a window that only shows during an application's startup. Do you mean a progress or "please wait" window?klugerama
Adding some kind of screenshot/example/code would be helpful for us to help you diagnose your problem.Tyler
It's my bad I'm using splash screen for my entire application. Now I am popping up a new window to display busy indicator inside my application. Thanks for your replies.user1118468

1 Answers

0
votes

you can try for BusyIndicator if suitable for you or else you can try below code to show Splash Window.

 void TemplateSelector_Loaded(object sender, RoutedEventArgs e)
        {
            showWin();

            Thread.Sleep(10000);


            CloseWin();

        }

        private void CloseWin()
        {
            WindowManager.Close();
        }
        Window tempWindow = new Window();
        public void showWin()
        {
            WindowManager.LaunchWindowNewThread<SplashWindow>();

        }
    }

    public class WindowManager
    {
        private static Window win;
        public static void LaunchWindowNewThread<T>() where T : Window, new()
        {
            Thread newWindowThread = new Thread(ThreadStartingPoint);
            newWindowThread.SetApartmentState(ApartmentState.STA);
            newWindowThread.IsBackground = true;

            Func<Window> f = delegate
            {
                T win = new T();
                return win;
            };

            newWindowThread.Start(f);
        }

        private static void ThreadStartingPoint(object t)
        {
            Func<Window> f = (Func<Window>)t;
            win = f();

            win.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            win.Topmost = true;
            win.Show();
            Dispatcher.Run();
        }
        public static void Close()
        {

            if (win != null)
                win.Dispatcher.BeginInvokeShutdown(DispatcherPriority.Send);

        }
    }