Prevent ribbon minimizing when double clicking on tab

Jul 26, 2010 at 12:53 PM
Hi, Is there a way to prevent the ribbon from minimizing when a user double clicks on any of the tabs? Thanks
Jul 27, 2010 at 10:28 AM
Edited Jul 27, 2010 at 10:56 AM

Yes you can add the MouseDoubleClick Event Handler to your Fluent:Ribbon xaml similar to: <Fluent:Ribbon Name="MyRibbon" MouseDoubleClick="MyRibbon_MouseDoubleClick">. 

Then in the event code add the line: this.MyRibbon.IsMinimized = false;

One comment, you may not want to do this.  When users double click on a Ribbon tab in office applications, the action toggles the minimized or maximized state of the Ribbon.  This is an intended behavior.  Hope this helps.  Kristi

Jul 27, 2010 at 1:46 PM

Hi KristiL. Thank you! It worked perfectly.

One other thing I've noticed is that when a user right clicks anywhere on the ribbon, there is an option in the context menu to minimise the ribbon.

There is also an arrow button on the top right corner of the window which I am trying to remove.

Do you know how I could remove both the option from the context menu and the arrow in the top right corner? Basically I'm trying to remove any method of minimising the ribbon since this interferes with my other UI controls. Thanks again.


Jul 27, 2010 at 5:54 PM

Hi ashjmcfox,


An alternative to trying to disable Ribbon features might be to re-size your application window based on the state of Ribbon options selected by the user. 


For example, make the application window (this.Height) larger when the Ribbon is fully displayed and smaller when the Ribbon is minimized.


One additional item that also affects the height the Ribbon consumes is the QAT feature of "Show below the Ribbon." When "Show below the Ribbon" is selected by the user the Ribbon requires extra height

and this may also interfere with your application workspace.


You can detect when the Ribbon size is changing by adding the SizeChanged Event Handler to your Fluent:Ribbon xaml similar to:  <Fluent:Ribbon Name="MyRibbon" SizeChanged="MyRibbon_SizeChanged">.


Then in the event code test attributes of the Ribbon and set the appropriate application height.  Not the most elegant solution, but it may work for you. For example:

private void MyRibbon_SizeChanged(object sender, SizeChangedEventArgs e) { double dBuildHeight = 0; //Value used to build the size of Ribbon area based on user settings double dQATHeight = 40; //Value to add extra height when the QAT is shown below the Ribbon area double dRibbonHeightMinimized = 50; //Value for height of Ribbon if the Ribbon is Minimized double dRibbonHeightMaximized = 85; //value for height of Ribbon if the Ribbon is Maximized double dMyApplicationControlHeight = 400; //Value for height of your control in the application window - you will need to determine this value if (this.MyRibbon.IsMinimized == true) { dBuildHeight = dRibbonHeightMinimized; } else { dBuildHeight = dRibbonHeightMinimized + dRibbonHeightMaximized; } if (this.MyRibbon.ShowQuickAccessToolBarAboveRibbon == true) { //in this case no additional space needed } else { dBuildHeight = dBuildHeight + dQATHeight; } this.Height = dMyApplicationControlHeight + dBuildHeight; }
If you try this, you should remove the MouseDoubleClick Event Handler.  The SizeChanged Event occurs when the user selects to Minimize the Ribbon, Maximize the 
Ribbon, Double Clicks on a Tab Item, and when ShowQuickAccessToolBarAboveRibbon value changes. Hope this helps.  Kristi


Jul 28, 2010 at 3:05 PM

Hi. I think I've found a solution. Many thanks for your help!