Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
495
Always open a new pane at the bottom of the screen MVVM
posted

Hi, I am working with a screen with an infinite vertical height (the entire contents of the xaml is encased in Scrollviewer)

 

When the screen first opens, there are two default panels, and the user has the option to add as many panels as he/she wants.

 

Everytime they open a new panel, I would like it to dock underneath any existing panels (so as the user adds panels, the screen fills up vertically, the scrollviewer becomes longer etc.)

 

This code works for me if I am trying to add a panel to the right side of the screen in MainViewModel.cs:

public void OpenPositionSummary()

        {

var view = _container.Resolve<PositionSummaryView>();

           view.DataContext = _container.Resolve<PositionSummaryViewModel>();

           

var region = RegionManager.Regions["DockedRight"];

           region.Add(view); //add the view

           region.Activate(view); //active the view

        }

 

 

But if I change the code to

public void OpenPositionSummary()

        {

var view = _container.Resolve<PositionSummaryView>();

           view.DataContext = _container.Resolve<PositionSummaryViewModel>();

          

var region = RegionManager.Regions["DockedBottom"];

           region.Add(view); //add the view

           region.Activate(view); //active the view

        }

 

I get an error.

 

 

How can I make it so that my viewmodel always adds panels to the bottom of whatever is currently on the screen?

 

Thanks