Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Caliburn.Micro Starting the bootstrapper from code?

Normally I just but the bootstrapper in the resources of the App.xaml, but for an app I'm building I need code execution to begin elsewhere and then start the bootstrapper up once I'm done my initialization code.

How can I start the bootstrapper?

I set the App.xaml to call a function as then did this:

using System.Windows;

namespace WpfApplication9
{
    public partial class App : Application
    {
        private AdminBootstrapper b;

        private void App_OnStartup(object sender, StartupEventArgs e)
        {
            //DO initialization

            b = new AdminBootstrapper();
            b.Start();
        }
    }
}

When I run nothing happens, and my view does not appear. I know the view/viewmodel work because if I put the bootstrapper in the resources section of the App.xaml it appears.

What am I doing wrong here?

like image 887
Kelly Avatar asked Feb 09 '26 21:02

Kelly


2 Answers

Use the Initialize() method instead of Start(). I had the same error and searched the internet and found a post that said to use Initialize() instead. I tried it on the sample app in the Caliburn.Micro docs and it worked for me.

like image 145
John Blacker Avatar answered Feb 15 '26 15:02

John Blacker


This is not the "correct" way to use the bootstrapper, the bootstrapper IS the place were you do the setup you talk of. The whole point is to provide a place were Caliburn.Micro knows you are going to set up. Without seeing your bootstrapper though it is impossible to know what is wrong.

The root ViewModel is not loaded until after Configure is called. This is your extensibility point. If you need to do complex configuration you could call a couple of overrides here and then derive a class which exposes these methods.

In general though you would need to provide more information about what you are doing before I could give you a concrete recipe.

like image 44
McDonnellDean Avatar answered Feb 15 '26 16:02

McDonnellDean



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!