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
260
TabControl "new Tab" button
posted

Hello,

How to make button next to last Tab for creating new Tab? I want similar mechanism like browsers have.

Would be nice also to have tabMenu and scrolls

Thank You for assistance

  • 34830
    Verified Answer
    Offline posted

    Hello WirtVest ERP,

    Thank you for your post.

    To create an "Add New" button next to the last tab in a XamTabControl, I would recommend an inclusion and modification of the default style of the XamTabControl. This default style can be found in the PrimitivesGeneric.xaml file commonly found at the following directory: C:\Program Files (x86)\Infragistics\<your version here>\WPF\DefaultStyles\Windows. I would recommend copying this style, and moving it into your application. Looking at the control template of the XamTabControl, you will notice a XamPager element with the x:Name "PART_TabItemScrollViewer", this is the tab area of the XamTabControl. I would recommend placing your "Add New" button directly after that XamPager element. You can then wire up a command to that button to add a new tab to the XamTabControl when the button is clicked.

    The only issue here is that when you add tabs to the point where the tabs start going out of view, the button will go out of view with it, by default. For this reason, I would recommend placing another button within the XamTabControl's PostTabItemContent. The XamTabControl has a property named IsTabItemPanelScrolling which determines whether or not the XamTabControl has items out of view or not. I would recommend that you toggle the visibilities of these "Add New" buttons based on the value of the XamTabControl.IsTabItemPanelScrolling property.

    For the tab menu, I would also recommend an addition to either the XamTabControl's PostTabItemContent or the PreTabItemContent. You can add a XamMenu to these areas and bind to the XamTabControl's Items collection to create a menu that displays all of the tabs.

    Regarding the scrolling functionality, would it be possible for you to elaborate a bit further on the functionality you are looking for? On my end, it appears that the XamTabControl already supports scrolling functionality if there are tabs that are out of the view of the tab area, and so it appears that this scrolling behavior for the tabs is already implemented.

    I have attached a sample project to demonstrate the above. For clarity purposes, I have placed the tab menu in the PreTabItemContent so that it doesn't conflict with the PostTabItemContent "Add New" button.

    I hope this helps you. Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer
    Infragistics Inc.
    www.infragistics.com/support

    XamTabControlFeaturesCase.zip