2011-04-21 128 views
3

我发现只有一种方法可以使飞溅显示时间延长。WPF飞溅屏幕,如何使飞溅屏幕显示更长

这正在改变ApplicationDefinition页面和配置它的时间。

但我需要ApplicationDefinition,我在这里找到了定位器,如果我使用页面,它会丢失。

所以我想让SpashScreen显示时间和延迟,然后再显示主窗体,但我也想保存ApplicationDefinition。

谢谢。

回答

5

Use the explicit way of showing the splash screen并将false传递给Show方法。

这样,当你想要关闭飞溅时,你必须明确调用Close()。

+0

SplashScreen自动使用.Net 4上的ApplicationDefinition自动运行 – Cynede 2011-04-21 10:47:46

+0

是的,但显然它不能按照你想要的方式工作,因为它只会等待所有资源加载。如果您想调整时间,则必须明确显示并关闭启动画面。 – 2011-04-21 11:26:32

+0

但也许只是为了制作一个把戏,并减缓这种负载... – Cynede 2011-04-21 11:57:39

3

我打开App.xaml文件,并进行了这些更改以“延迟”显示。

public partial class App : Application 
{ 
    App() 
    { 
     // Pause to show the splash screen for 3 seconds 
     System.Threading.Thread.Sleep(3000); 
    } 
} 
+1

一个冻结UI线程的vad解决方案。更好地使用TAP'等待TaskEx.Delay(1000)' – nikeee 2012-10-02 10:04:26

2

您可以使用,如杰克Glines写道:System.Threading

using System.Threading; 

public MainWindow() 
{   
    SplashScreen splash = new SplashScreen("splash.jpg"); 
    splash.Show(true); 
    Thread.Sleep(1500);   
    InitializeComponent(); 
} 

或者您也可以使用它定时器/进度,并使其依赖于真实负载,而不是虚构的。

0

另一种方法是找到App.g.cs文件及其主要():

public static void Main() { 
     SplashScreen splashScreen = new SplashScreen(“splash.jpg"); 
     splashScreen.Show(true); 
     Thread.Sleep(3000);   
     someNameSpace.App app = new someNameSpace.App(); 
     app.Run(); 
    } 

其中唯一的新增加的字段是Thread.Sleep(3000);,这将3秒延迟启动画面的表示。