WPF啟動屏幕SplashScreen


 

SplashScreen類為WPF應用程序提供啟動屏幕。

 

方法一:設置圖片屬性

1. 添加啟動圖片到項目中

2. 設置圖片屬性的Build Action為SplashScreen

   

 

方法二:編寫代碼

1. 在App.xaml.cs中重寫OnStartUp方法:

 1 using System;
 2 using System.Windows;
 3 
 4 namespace StaticLanguageSelect
 5 {
 6     /// <summary>
 7     /// Interaction logic for App.xaml
 8     /// </summary>
 9     public partial class App : Application
10     {
11         protected override void OnStartup(StartupEventArgs e)
12         {
13             //根據圖片路徑,實例化啟動圖片
14             SplashScreen splashScreen = new SplashScreen("\\3-2.png");
15             splashScreen.Show(false);
16 
17             //上面Show()方法中設置為true時,程序啟動完成后啟動圖片就會自動關閉,
18             //設置為false時,啟動圖片不會自動關閉,需要使用下面一句設置顯示時間,例如5s
19             splashScreen.Close(new TimeSpan(0,0,5));
20 
21             base.OnStartup(e);
22         }
23     }
24 }
 
        

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM