RibbobBar hiding with multiple mouse clicks

Mike Charlesworth 20 Reputation points
2024-05-01T09:48:25.9+00:00

Our application has a RibbonBar containing several tabs. In it we have disabled the ability to shrink the ribbon bar by double clicking on the tab headers by intercepting the PreviewMouseDoubleClick event and marking it as handled.

This works fine for a couble click.

However we have now discovered that a triple click will also hide the ribbon bar. The double click handler is called but has no effect.

Has anybody else seen this behaviour? How can we stop it?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,433 questions
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,685 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 112.8K Reputation points
    2024-05-01T12:21:32.17+00:00

    Try something like this:

    [DllImport( "user32" )]
    public static extern int GetDoubleClickTime( );
    
    int ts = 0;
    
    private void Ribbon_PreviewMouseDoubleClick( object sender, MouseButtonEventArgs e )
    {
        e.Handled = true;
        ts = e.Timestamp;
    }
    
    
    private void Ribbon_PreviewMouseDown( object sender, MouseButtonEventArgs e )
    {
        e.Handled = e.Timestamp - ts <= GetDoubleClickTime( );
        ts = e.Timestamp;
    }
    

    Add the PreviewMouseDown in XAML.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful