WPF 应用程序窗口出现在 SplashScreen 顶部

发布于 2024-08-08 21:48:34 字数 311 浏览 3 评论 0原文

我按照如何:向 WPF 应用程序添加启动屏幕中概述的简单步骤进行操作 向我的 WPF 应用程序添加启动屏幕。当我启动应用程序时,会显示启动图像,然后弹出主窗口,然后启动图像消失。

我的问题是,当主窗口弹出时,它出现在启动图像的顶部。然后,当启动图像开始淡出时,启动图像再次弹出到顶部。最终结果是,当主窗口出现时,启动图像瞬间消失。

如何强制主窗口出现在启动图像下方,以使启动图像不会消失?

I followed the simple steps outlined at How to: Add a Splash Screen to a WPF Application to add a splash screen to my WPF application. When I start the application, the splash image is shown, then the main window pops up, and the splash image fades away.

My problem is that when the main window pops up, it appears on top of the splash image. Then when the splash image begins to fade out, the splash image pops up to the top again. The end result is that the splash image disappears for a split second as the main window appears.

How can I force the main window to appear under the splash image, so that the splash image does not disappear?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

虚拟世界 2024-08-15 21:48:34

在 .NET 4.0 中,重载已添加到 Show() 方法,允许在启动屏幕窗口上设置窗口样式 WS_EX_TOPMOST。在如下代码中显示启动屏幕:

SplashScreen splash = new SplashScreen("SplashScreen.png");
splash.Show(autoClose: true, topMost: true);

方法调用该屏幕

protected override void OnStartup(StartupEventArgs e)

我从App.xaml.cs 中的

。 “SplashScreen.png”当然是嵌入在应用程序资源中的启动图像的标识符。

In .NET 4.0 an overload has been added to the Show() method that allows to set the window style WS_EX_TOPMOST on the splash screen window. Show the splash screen in code like this:

SplashScreen splash = new SplashScreen("SplashScreen.png");
splash.Show(autoClose: true, topMost: true);

I call that from the method

protected override void OnStartup(StartupEventArgs e)

in App.xaml.cs.

"SplashScreen.png" is of course the identifier for your splash image embedded in the application's resources.

浪荡不羁 2024-08-15 21:48:34

这不是默认行为,您必须有一些代码来手动聚焦主窗口吗?

使用如下代码手动关闭淡入淡出可能会更容易:

_splash = new SplashScreen("LoadingScreen.png");`
_splash.Show(false);`
_splash.Close(TimeSpan.Zero); `

This isn't default behaviour you must have some code thats manually focusing the main window?

It may be easier just to turn off the fade manually with a bit of code like this:

_splash = new SplashScreen("LoadingScreen.png");`
_splash.Show(false);`
_splash.Close(TimeSpan.Zero); `
难以启齿的温柔 2024-08-15 21:48:34

不确定这是否有帮助,但如果您将启动屏幕的所有者设置为当前表单,那么这也许可以解决问题?

_splash.Owner = this;

否则,您可以查看此处:

启动屏幕示例

这也可能有帮助。

Not sure if this will help, but if you set the owner of the Splash screen to the current form, then this should maybe do the trick?

_splash.Owner = this;

Otherwise you can look here:

Splash Screen Example

This might help too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文