###前提・実現したいこと
C#とWPFでスプラッシュスクリーンの実装をしているのですが、表示→処理→MainWindow表示の流れがよくわかりません。
なぜスプラッシュスクリーンを表示しているのかと言うと、アップデート処理を可視化するためであり、MainWindowを表示するのに何らかの処理が必要だとかそういうことではありません。
###該当のソースコード
WinSplash.xaml.cs
C#
1 2#region Using文 3using System; 4using System.Collections.Generic; 5using System.ComponentModel; 6using System.Linq; 7using System.Text; 8using System.Threading.Tasks; 9using System.Windows; 10using System.Windows.Controls; 11using System.Windows.Data; 12using System.Windows.Documents; 13using System.Windows.Input; 14using System.Windows.Media; 15using System.Windows.Media.Imaging; 16using System.Windows.Shapes; 17#endregion 18 19namespace MineLab 20{ 21 22 #region WinSplashクラス 23 public partial class WinSplash : Window 24 { 25 26 public WinSplash() { InitializeComponent(); } 27 28 //ここに色々な処理が入りそうだけどよくわからない。 29 30 } 31 #endregion 32 33} 34
App.xaml.cs
C#
1using System; 2using System.Collections.Generic; 3using System.Configuration; 4using System.Data; 5using System.Linq; 6using System.Threading.Tasks; 7using System.Windows; 8 9namespace MineLab 10{ 11 12 public partial class App : Application 13 { 14 15 private WinSplash _splash; 16 public WinSplash Splash { get; private set; } 17 18 [STAThread] 19 public static void Main() 20 { 21 22#if DEBUG 23 24 var _msg = MessageBox.Show("現在Alphaビルドが起動しています。\n\rAlphaビルドは最新の技術が盛り込まれていますが、非常に不安定です。\n\r続行しますか?", "MineLab", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); 25 26 if (_msg != MessageBoxResult.Yes) { return; } 27 28#endif 29 30 App _app = new App(); 31 _app.Run(); 32 33 } 34 35 public App() : base() 36 { 37 38 Startup += ShowSplash; 39 40 } 41 42 [STAThread] 43 private void ShowSplash(object sender, StartupEventArgs e) 44 { 45 46 Splash = new WinSplash(); 47 Splash.Show(); 48 49 } 50 51 } 52}

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2016/11/25 07:20