WPF 应用程序窗口出现在 SplashScreen 顶部
我按照如何:向 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 .NET 4.0 中,重载已添加到
Show()
方法,允许在启动屏幕窗口上设置窗口样式WS_EX_TOPMOST
。在如下代码中显示启动屏幕:方法调用该屏幕
我从
App.xaml.cs
中的。 “SplashScreen.png”当然是嵌入在应用程序资源中的启动图像的标识符。
In .NET 4.0 an overload has been added to the
Show()
method that allows to set the window styleWS_EX_TOPMOST
on the splash screen window. Show the splash screen in code like this:I call that from the method
in
App.xaml.cs
."SplashScreen.png" is of course the identifier for your splash image embedded in the application's resources.
这不是默认行为,您必须有一些代码来手动聚焦主窗口吗?
使用如下代码手动关闭淡入淡出可能会更容易:
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:
不确定这是否有帮助,但如果您将启动屏幕的所有者设置为当前表单,那么这也许可以解决问题?
否则,您可以查看此处:
启动屏幕示例
这也可能有帮助。
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?
Otherwise you can look here:
Splash Screen Example
This might help too.