Caliburn Launch 不带 App.xaml,但带有引导程序
我有一个 WinForms 项目,我想从 WPF 用户控件项目中打开 WPF 窗口。 但是,当我创建 WPF 窗口的实例并调用 Show() 时,引导程序未加载。在 Windows 应用程序中,它位于 App.xaml 中,但用户控件项目没有它。 我能做些什么? 谢谢!
I have a WinForms project from which I want to open a WPF window from a WPF user control project.
But when I create an instance of the WPF window and call Show(), the bootstrapper isn't loaded. In an Windows Application, it's located in the App.xaml, but an user control project doesn't have this.
What can I do?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
通过将引导程序放在 App.xaml 的资源中,唯一完成的事情是引导程序的实例化并保留引用,以便它不会被垃圾收集。您可以尝试像这样实例化它:
这将确保它作为静态构造的一部分进行初始化,这会在您创建
SomeClass
实例之前发生。您可能必须进行试验,看看这种情况是否应该发生在您的用户控件中或您的窗口中。The only thing accomplished by having the bootstrapper in App.xaml's resources is instantiation of the bootstrapper and keeping a reference so it isn't garbage-collected. You could try making it instantiate like this:
That will make sure it's initialized as part of static construction, which happens sometime before you can create an instance of
SomeClass
. You may have to experiment to see whether that should happen in your UserControl or in your Window.我有一个控制台应用程序,它提供了我用 Caliburn.Micro 制作的 WPF gui。我这样展示 GUI:
其中 App.xaml 包含引导程序,主线程是 STA,如下所示:
我知道您的情况有所不同,但也许这会给您一个想法。
I have a console application which presents a WPF gui that I made with Caliburn.Micro. I present the GUI like this:
Where App.xaml contains the bootstrapper and the main thread is STA like this:
I know your situation is different but maybe this will give you an idea.
控制台应用程序测试:
Console application test: