We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How to control ribbon tabs programmatically

I am using the latest WPF Ribbon control.
 
How do I programmatically (a) select a particular ribbon tab (b) show/hide a particular ribbon tab?
 
Thanks for any pointers.
 

6 Replies

PE Peter May 24, 2015 08:58 AM UTC

OK, (b) is obvious: 
      tab1.Visibility = Visibility.Visible
or   tab1.Visibility = Visibility.Collapsed
 
But (a) less so: 
      tab1.IsChecked = true  
 

But this does not suffice to hide a ribbon tab's contents, only hide the tab's label. So hiding a tab requires switching to another:

      tab1.IsChecked = false
      tab1.Visibility = Visibility.Collapsed
      tab2.Visibility = Visibility.Visible
      tab2.IsChecked = true

 



MS Mariappan S Syncfusion Team May 25, 2015 01:17 PM UTC

Hi Peter,

Thank you for contacting Syncfusion support.

In our current implementation of Ribbon control, we can control the RibbonTab using the properties "Visibility". While the particular RibbonTab visibility is collapsed, the first RibbonTab will get selected. This is the behavior of RibbonTab. Can you please explain your requirement clearly, it would help us to solve the problem earlier
Please let us know if you need further assistance.

Regards,
Mariappan S.


PE Peter May 26, 2015 07:22 AM UTC

You ask me to explain my requirements further and you say: "While the particular RibbonTab visibility is collapsed, the first RibbonTab will get selected. "
 
My requirements are to make a certain ribbon tab normally invisible (collapsed) but in a certain context (user selection of a particular page in the application) this tab to become both visible and selected. When I say "selected" I mean as if the tab was always visible and the user clicked on this tab.
 
My application has 3 ribbon tabs: "Schematic" (visible), "Model" (visible) and "Chart" (normally collapsed). Ideally I want the "Chart" tab to become both visible and the currently selected tab in a certain context (see Q3 below) but so far I've only managed to make this work using explicit code.
 
In the 3 images at http://postimg.org/gallery/1xedllhlg/ you will see:
 
Images #1. "Chart" tab Visibility is Collapsed. Tab and its contents are invisible and the first ("Schematic") tab is shown. Correct.
 
Image #2. "Chart" tab Visibility set to Visible and IsChecked set to true. The "Chart" tab and its contents are now the currently selected tab. Correct.
 
Image #3. "Chart" tab Visibility set back to Collapsed. The tab label is invisible but the tab contents remain visible and selected. It does not behave like your statement above. As far as I can tell the extra step required is to set IsChecked = true on some other tab.
 
So my followup questions are:
 
1. Is the "Visibility" property supposed to only affect the tab label and not the tab contents (as I find above)?
 
2. Is the "IsChecked" property the correct way to select (make current) a particular tab in code?
 
2. Do you have any examples of the use of the ContextTabGroup? This feels like what I should be using but the one page of documentation on this is completely lacking on what it does or how to use it.
 
 
 
 
 
 


MS Mariappan S Syncfusion Team May 28, 2015 09:54 AM UTC

Hi Peter,

We were able to reproduce the issue and have logged defect report regarding this. A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Please let me know if you have any questions.

Regards,
Mariappan S


LU LUGNIER November 4, 2019 07:51 PM UTC

Hi, 
to select a tab by his title

_ribbonMain is my Ribbon.

private void SelectTab(String title)
        {
            RibbonTab rt = null;
            foreach (RibbonTab tab in _ribbonMain.Items)
            {
                if (tab.Caption == title)
                {
                    rt = tab;
                }

                tab.IsChecked = false;
            }

            if (rt != null)
            {
                rt.IsChecked = true;
            }
        }

Hope this will help

Benoist LUGNIER


VR Vijayalakshmi Roopkumar Syncfusion Team November 6, 2019 06:21 AM UTC

Hi LUGNIER 
 
Thank you for using Syncfusion Products. 
 
Yes, to select the tab with the RibbonTab tilte, you can use the above mentioned approach. 
 
Please let us know if you need any other assistance on this. 
 
Regards 
Vijayalakshmi V.R. 


Loader.
Live Chat Icon For mobile
Up arrow icon