0

I want to choose which user control to load but my MainWindowView is not even loaded yet so the region manager does not know any regions, How can I achieve this?

my bootstrapper looks like this:

    protected override DependencyObject CreateShell()
    {
        return this.Container.Resolve<MainWindowView>();
    }

    protected override void InitializeShell()
    {
        Application.Current.MainWindow.Show();
    }

    protected override void ConfigureContainer()
    {
        base.ConfigureContainer();

        this.Container.RegisterTypeForNavigation<WorkTypeSelectionView>();
    }

and my viewmodel:

    public MainWindowViewModel(IEventAggregator eventAggregator, IRegionManager regionManager)
    {

        this.eventAggregator = eventAggregator;
        this.regionManager = regionManager;
        this.AuthenticateUser();

        if (this.LoggedUser.AvailableWorkTypes.Count > 1)
        {
            this.Navigate(nameof(WorkTypeSelectionView));
        }
    }

    private void Navigate(string obj)
    {
        this.regionManager.RequestNavigate(DefaultContentRegion, obj);
    }

thanks in advance!

EDIT:

Guess i was asking the wrong question, found this https://stackoverflow.com/a/7887936/171136 still want to explore other options. Thanks!

Community
  • 1
  • 1
Luiscencio
  • 3,855
  • 13
  • 43
  • 74

1 Answers1

1

You can use View Discovery with regionManager.RegisterViewWithRegion("RegionName", typeof(View));. When the region is created, it will automatically inject the view.