如何使用 Caliburn Micro 显示启动屏幕
我正在将 Caliburn Micro v1.3 与 WPF 结合使用。我想在加载应用程序时显示启动屏幕。
我已经重写了 OnStartup,如下所示,但看不到如何在 base.OnStartup 完成时关闭启动画面
protected override void OnStartup(object sender, System.Windows.StartupEventArgs e)
{
var wm = new WindowManager();
var vm = new StatusReporterViewModel("TEST", "information", null);
try
{
wm.ShowWindow(vm);
base.OnStartup(sender, e);
}
finally
{
vm.TryClose();
}
}
有什么想法吗?
干杯
史蒂夫
I'm using Caliburn Micro v1.3 with WPF. I would like to display a splash screen while my app loads.
I have overriden OnStartup as below but can't see how to close my splash when the base.OnStartup complete
protected override void OnStartup(object sender, System.Windows.StartupEventArgs e)
{
var wm = new WindowManager();
var vm = new StatusReporterViewModel("TEST", "information", null);
try
{
wm.ShowWindow(vm);
base.OnStartup(sender, e);
}
finally
{
vm.TryClose();
}
}
Any ideas?
Cheers
Steve
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想使用默认的 WPF 启动机制,则不需要任何代码。
将图像文件添加到 WPF .EXE 项目,然后将图像的属性设置为“SplashScreen”
If you want to use the default WPF splash mechanism then it requires no code.
Add an image file to your WPF .EXE project and then set the properties on the image to "SplashScreen"
如果您的启动屏幕是一个实际的自定义窗口,您可以在 ShellViewModel 的 OnInitialize() 方法中关闭启动屏幕(或者如果您没有 shell,则关闭第一个视图模型)。要在 Shell 中获取对 SplashScreen 的引用,请将其注入或使其成为单例
If your Splash Screen is an actual customized Window, you can close the SplashScreen in the OnInitialize() Method of your ShellViewModel (or if you dont have a shell, the first view model that gets activated). To get a reference to the SplashScreen in your Shell either inject it or make it a singleton