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
40
Set back Ribbon.SelectedTab to PreviousSelectedItem
posted

Hi,

is it possible to set back the SelectedTab of the Ribbon to the PreviousSelectedItem without throwing the RibbonTabItemSelected-Event?

I tried to de-register the Event, set the Tab and registered it again, but the Event is handled once again with the same PreviousSelectedTab and NewSelectedTab in the Event Args.

Sample:

private void ribbonControl_RibbonTabItemSelected(object sender, Infragistics.Windows.Ribbon.Events.RibbonTabItemSelectedEventArgs e)
{
    this.ribbonControl.RibbonTabItemSelected -=
        new EventHandler<Infragistics.Windows.Ribbon.Events.RibbonTabItemSelectedEventArgs>(ribbonControl_RibbonTabItemSelected);
    this.ribbonControl.SelectedTab = e.PreviousSelectedRibbonTabItem;
    this.ribbonControl.RibbonTabItemSelected +=
        new EventHandler<Infragistics.Windows.Ribbon.Events.RibbonTabItemSelectedEventArgs>(ribbonControl_RibbonTabItemSelected);
}

What we want to do is simple: If a specified Flag is set (e.g. EditMode), we won't allow the User to switch the Tab.

 

Best Regards.

Parents
No Data
Reply
  • 54937
    Verified Answer
    Offline posted

    While I can understand why you want to do this, I would recommend reviewing the Microsoft Office UI Guidelines; they specifically indicate that clicking a tab must show the contents for that tab. According to your license agreement with Microsoft which allows you to use the Ribbon UI in your application you must follow the guidelines they set forth. With regards to the specific question, if this were allowed then you would probably need to delay the processing (i.e. use a Dispatcher.BeginInvoke) and not try to process it in that event as other state is still being initialized. Note even if this did work the other element that was in edit mode, etc. would likely still have lost focus.

Children
No Data