所以现在的情况是,我正在开发一个C# WPF桌面应用程序,并希望在程序启动时添加一个闪屏界面。
但我没有使用SplashScreen类,而是在应用程序顶部使用了一个同名的额外WPF窗口类,并将该类称为“Splashy”。
我的闪屏界面有一个动态GIF图像,在下面的Splashy类的WebBrowser控件上进行动画效果良好...
<Image gif:ImageBehavior.AnimatedSource="Images/FSIntro.gif" Margin="10,1,0,10">
<Image.OpacityMask>
<ImageBrush ImageSource="Images/FSIntro.gif"/>
</Image.OpacityMask>
</Image>
...而 Splashy 类本身是在 App.XAML 中作为 StartupUri 初始化的。
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
... ...
... (some text) ...
... ...
StartupUri="Splashy.xaml">
<Application.Resources>
但这种情况的问题在于启动画面卡住了,无法进入主程序本身。
所以我尝试了一种不同的方法,使用代码。
当我将以下代码实现到启动画面中,并将其实现到我的程序中以运行启动画面并显示主屏幕时,启动画面会按照我想要的方式执行,但它不会像我希望的那样动画化。
下面是Splashy类代码。
public partial class Splashy : Window
{
public Intro()
{
InitializeComponent();
}
public void Outro()
{
this.Close();
}
}
以下是程序实现启动画面的方法。
public partial class LoginScreen : Window
{
Splashy splash = new Splashy();
public LoginScreen()
{
splash.Show();
Thread.Sleep(5000);
splash.Outro();
// home screen
}
}
任何建议和帮助都将不胜感激。