Hi,
I've written some code for adding a ContentPane to a TabGroupPane. So far so good:
view.TabsGroup.Items.Add(contentPane);view.TabsGroup.SelectedItem = contentPane;
where view.TabsGroup is a TabGroupPane and contentPane is a ContentPane.
The issue is that the new tab always appears at the beginning (e.g. it is always the leftmost), while I want them to appear at the end. I tried:
view.TabsGroup.Items.Insert(view.TabsGroup.Items.Count, contentPane);view.TabsGroup.SelectedItem = contentPane;
but the issue persists. it appears that the order is not taken into account.
Any ideas?
Thanks,Sam
This TabGroupPane must be within the DocumentContentHost. If so then this is the expected behavior. The TabGroupPane in the DocumentContentHost is designed to emulate the tabbed interface of VS and in VS when a pane is selected and is not in view then it will be moved into view (by making it the first tab item). The only way to prevent that would be to use a different ItemsPanel. By default the TabGroupPane in a DocumentContentHost uses our DocumentTabPanel which only creates elements for the tabs fully in view (as VS does). Note if you do use a different ItemsPanel (e.g. our TabItemPanel) you will likely alo need to retemplate the TabGroupPane since there will be no scroll elements in that template (since the tabbed interface doesn't support scrolling). Our default template has a key of TabGroupPane.DocumentTabGroupTemplateKey.
Thank you for your reply.
I realize what you're saying and it would make sense for Items.Add. However the fact that Items.Insert does not respect the index being provided (or that apparently there is no way to programmatically rearrange the order of tabs) sounds more like a bug to me.
Consider that the collection of tabs in Items is sorted (if you rearrange tabs from the UI you can see the change in the list). So it would make sense to me to be able to insert at any position. Even more so given that the API provides a method especially conceived for that.
I will give it a try for the re-templating using TabItemPanel, but please consider opening a ticket for the behavior.
If this is by design, and developers obviously want different behavior, is there a way to re-arrange the tabs after the add? I don't see an easy way to do this.
I'm sorry but this is not a bug but is as it was designed in order to emulate the VS tabbed document functionality. The Insert will insert at the specified position. What is happening is that the Selected TabItem of the TabGroupPane in the DocumentContentHost must be kept in view - this is the same behavior as you see in VS. So if the SelectedItem is determined to be out of view, we do what VS does which is to bring the tab item into view and that moves the item in the collection to be the first item.