How to Add a New Tab to a Specific Tab Group in TabbedMdiHost When Dropping an Item

Docking/MDI for WPF Forum

The latest build of this product (v24.1.2) was released 3 months ago, which was before this thread was created.
Posted 2 months ago by miles
Version: 24.1.2
Avatar

Hello,

I am using TabbedMdiHost and have set a custom behavior for the ItemsPanel template by using an AdvancedTabPanel. This allows me to add a new tab and display the dropped item when an item is dropped in the AdvancedTabPanel area.

However, when multiple tab groups are present, the new tab is added to the currently active tab group instead of the tab group where the item was dropped. This is causing an issue for my implementation.

I would like to know if the following functionalities are available:

  1. Can we identify the tab group where the AdvancedTabPanel, where the item was dropped, is located?
  2. Can we specify a tab group in TabbedMdiHost to add a new tab to?

Thank you in advance for your assistance.

Comments (3)

Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

By "item", do you mean you are using MVVM techniques here?  If not, can you clarify what you mean by an item?

In general if you open a document without specifying a target, it will open in the tabbed MDI container that contains the current primary document (document that was last focused). 

If you are trying to open a document in another tabbed MDI container, you could do any one of these things:

1) Instead of calling the document's Open() method, call the Attach(targetTabbedMdiContainer) method.  This will add a tab to the target tabbed MDI container and is the best option if you are programmatically adding the document.

2) Activate the selected document in the target tabbed MDI container prior to opening the new document.  When the new document is opened, it would to go that tabbed MDI container.

3) Handle the DockSite.WindowDefaultLocationRequested event and specify the e.Target as the target tabbed MDI container and use e.Side = null.

Any of those should work, but the first is preferable.

[Modified 1 month ago]


Actipro Software Support

Posted 1 month ago by miles
Avatar

Thank you for your response.

Yes, we are using an MVVM architecture, and the "item" being dropped refers to the ViewModel in the MVVM pattern.

Your suggested methods are helpful, and we will consider implementing them. However, I have an additional question.

Currently, we are adding a new item as a tab using the following steps:

  1. We add the ViewModel, which represents the item, to the ObservableCollection bound to DockSite.DocumentItemsSource.
  2. We set the IsOpen property of the ViewModel to true, which results in a new tab being added to the view. This works because the IsOpen property of the ViewModel is bound to the IsOpen property of the DockingWindow.

Given this setup, is there a way to detect a change in a specific property of the ViewModel and add a new tab to a specific tab group accordingly?

Answer - Posted 1 month ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Miles,

If you are using MVVM with ViewModel items for the document windows and are opening them with IsOpen=true, then you want to focus on using the options in the "Default Locations" section of this documentation topic.

One option would be to set the WindowGroupName of the ViewModel to the same WindowGroupName of another ViewModel that is already open.  The open logic first tries to find a match of those with an existing document window and will try to "attach" (become tabbed) with that target document window.

Beyond that, you could handle one of the DefaultLocationRequested-related events and update the event args.  You'd specify the e.Target as the target tabbed MDI container and use e.Side = null.


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.