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
905
TabGroupPane that is in DocumentContentHost works wrongly
posted

Hi,

I am using TabgroupPane in DocumentContentHost. I want to add new tab at the end of the tabgroup and after that I want to activate new tab content. But when I add a new tab into tabgroup from code behind, new tab is placed first order and appears as first tab.

If tabgrouppane is out of DocumentContentHost it works well, but other way it does not work.

And If I do not set selectedItem it works well but I want to activate new tab at the last order.

 I tried to show this problem with an example project that was attached this message.

Any solution ? Is this a bug ?

TabControl Arge.rar
  • 54937
    Verified Answer
    Offline posted

    Instead of setting the SelectedItem you should call the Activate method. Note even then though the TabGroupPane emulates the behavior of VS when a pane is activated/selected - that is it is brought to the beginning of the list if its not in view - so when you add enough tab items such that the tab would not be in view it will be brought to the beginning.  The only way to prevent that would be to use a different ItemsPanel - e.g. TabItemPanel. The default panel used for a TabGroupPane in the DocumentContentHost is a DocumentTabPanel which is a custom virtualized panel that only generates the first X elements that fit in view. If you do this though you will probably have to retemplate the TabGroupPane as well since the default template (the one keyed by TabGroupPane.DocumentTabGroupTemplateKey) for this area does not include any scrolling elements since they are not needed/used in VS.