WPF: 启动界面的实现

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>
相关推荐
悟空聊架构18 分钟前
我的网站被攻击了,被干掉了 120G 流量,还在持续攻击中...
java·前端·架构
hqwest31 分钟前
C#WPF实战出真汁08--【消费开单】--餐桌面板展示
c#·wpf·ui设计·wpf界面设计
orangapple34 分钟前
WPF 打印报告图片大小的自适应(含完整示例与详解)
c#·wpf
陈天伟教授41 分钟前
(二)Python + 地球信息科学与技术 (GeoICT)=?
开发语言·python
Dajiaonew1 小时前
Spring AI RAG 检索增强 应用
java·人工智能·spring·ai·langchain
IT古董4 小时前
第四章:大模型(LLM)】06.langchain原理-(3)LangChain Prompt 用法
java·人工智能·python
轻抚酸~7 小时前
小迪23年-32~40——java简单回顾
java·web安全
Sirius Wu9 小时前
Maven环境如何正确配置
java·maven
七七&5569 小时前
2024年08月13日 Go生态洞察:Go 1.23 发布与全面深度解读
开发语言·网络·golang
java坤坤10 小时前
GoLand 项目从 0 到 1:第八天 ——GORM 命名策略陷阱与 Go 项目启动慢问题攻坚
开发语言·后端·golang