Hi,
We use the XamDockManager control to have a flexible layout. We added a button to the right of the tabs that allows us to open a new tab with a certain content.
When a tab is dragged to another window (or a new window is created) the same button is added as well. However when we click on the new tab button the new tab always appears in the main window.
To create a new tab we use the following code:
RegionManager.Regions[parameters.Region].Activate(view);
Is it possible to open tabs in another screen (and optionally specify which screen?)
Kind regards
In order to accomplish this you need to add a bit of extra code. First off you need to create a new scoped region manager and region for each TabGroupPane that is created when dragging ContentPanes around. Next, when you click your button, you need to access the region manager of the selected TabGroupPane, and then add your view to that region. I have solved this for you by creating a new region behavior which handles all the heavy lifting. The only thing you have to do is add the TabGroupPane to the button's CommandParameter. You might need to make some changes to fit your needs exactly, but this should get you started.
Ok that works! Thanks!
I have one more question concerning the creation of a tab that is automatically opened in a new window. (But can be dragged tot the XamDockManager).
In your sample I'm able to do this using the following code:
private void OpenNewWindow() { ContentPane cp1 = new ContentPane(); cp1.Header = "Content Pane 1"; ContentPane cp2 = new ContentPane(); cp2.Header = "Content Pane 2";
TabGroupPane tabGroupPane = new TabGroupPane(); // Add ContentPanes in TabGroupPane Panes collection tabGroupPane.Items.Add(cp1); tabGroupPane.Items.Add(cp2);
SplitPane splitPane = new SplitPane();
// Add the TabGroupPane and the ContentPane in SplitPane Panes collection splitPane.Panes.Add(tabGroupPane); XamDockManager.SetInitialLocation(splitPane, InitialPaneLocation.DockableFloating);
DockManager.Panes.Add(splitPane); }
However in the real application we use the RequestNavigate method from an IRegionManager. We use this method to pass parameters to the new tab.
Is it possible to combine these two approaches?
Kind Regards!
Yes. You just have to write the code required to support your scenario. Make sure you call RequestNavigate on the correct RegionManager.
I am just checking if you have any other questions on the matter.
If Brian’s response helped you implement the functionality you need, please mark it as Answer so other community members may benefit from this thread as well. Thank you.
Brian, Maria,
I still have issues implementing the behavior to open a tab in a new window. I tried combining the two approaches described above with the following code, but i haven't gotten any further that the provided code below:
//Here I create the new window that is linked to the dockmanager
#region CREATION OF THE NEW WINDOW TabGroupPane tabGroupPane = new TabGroupPane(); SplitPane splitPane = new SplitPane(); // Add the TabGroupPane and the ContentPane in SplitPane Panes collection splitPane.Panes.Add(tabGroupPane); XamDockManager.SetInitialLocation(splitPane, InitialPaneLocation.DockableFloating); parameters.DockManager.Panes.Add(splitPane); #endregion
//Then i create a new region that is linked to the tabGoupPane
//IRegion mainRegion = RegionManager.Regions[regionName]; string regionName = RegionNames.MainRegion + DateTime.Now.Ticks.ToString(); Region region = new Region(); region.Name = regionName; region.RegionManager = _regionManager; region.NavigationService = new CustomRegionNavigationService(ServiceLocator, new CustomRegionNavigationContentLoader(ServiceLocator), ServiceLocator.GetInstance<IRegionNavigationJournal>()); _regionManager.Regions.Add(region);
tabGroupPane.SetValue(Microsoft.Practices.Prism.Regions.RegionManager.RegionNameProperty, regionName); Microsoft.Practices.Prism.Regions.RegionManager.SetRegionName(tabGroupPane, regionName);
//Then I request the region to move to the MainWorkSpaceView
_regionManager.RequestNavigate(regionName, new Uri(ViewNames.MainWorkspaceView + query.ToString(), UriKind.Relative), (NavigationResult nr) => {
...... // code is added here that fills up the UI of the MainWorkspaceView
}
At this point an invalid operation exception is thrown (in the RequestNavigate method).
Many thanks in advance!