0
点赞
收藏
分享

微信扫一扫

微信答题小程序产品研发-前端开发

爱奔跑的读书者 2024-08-13 阅读 19

1.App.xaml

 public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            SplashScreen spl = new SplashScreen("xxx.jpg");
            spl.Show(false);
            spl.Close(new TimeSpan(0, 0, 3));//设置关闭启动界面的时间
            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(3); // 倒计时3秒
            timer.Tick += (s, args) =>
            {
                timer.Stop();
                
                base.OnStartup(e);
            };
            timer.Start();
        }


        private void Application_Startup(object sender, StartupEventArgs e)
        {

            // 启动主窗口
            MainWindow mainWindow = new MainWindow();
            mainWindow.Show();
        }

2.App.xmal

<Application x:Class="Appliaction类.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:Appliaction类"
           ShutdownMode="OnLastWindowClose"
          
             Startup="Application_Startup"<!--使用这个事件-->
             >   <!--  StartupUri="MainWindow.xaml"注释掉 -->
    <Application.Resources>
         
    </Application.Resources>
</Application>
举报

相关推荐

0 条评论