开发者

Caliburn Launch without App.xaml, but with bootstrapper

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 i开发者_如何学编程sn'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!


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:

public class SomeClass {
    static Bootstrapper _bs = new Bootstrapper();

    ...
}

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.


I have a console application which presents a WPF gui that I made with Caliburn.Micro. I present the GUI like this:

        _App = new App();
        _App.Run();

Where App.xaml contains the bootstrapper and the main thread is STA like this:

[STAThread]
static int Main(string[] args)
{ ... }

I know your situation is different but maybe this will give you an idea.


Console application test:

Add MaterialDesignColors pakage

[System.STAThreadAttribute()]
static void Main(string[] args)
{
    var _app = new App();
    _app.InitializeComponent();        
    _app.Run();    
    _app.Shutdown();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜