0

我正在开发一个 WPF 应用程序。我正在使用两台显示器。当某些功能正在执行时,我正在使用启动画面在窗口上弹出。

我遇到的问题是,当我将应用程序移动到辅助监视器并开始处理功能时,启动画面仍显示在主监视器而不是辅助监视器上。

对此有什么帮助吗?

4

1 回答 1

0

如果适合您,您可以尝试BusyIndi​​cator ,否则您可以尝试以下代码来显示 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);

        }
    }
于 2013-10-09T16:07:22.973 回答