New to Telerik UI for WPF? Download free 30-day trial

Override Esc Key Logic of RadRibbonBackstage

Environment

Product Version 2023.2.606
Product RadRibbonView for WPF

Description

How to override Escape key logic of the RadRibbonBackstage element.

Solution

To achieve this requirement, create a custom class that derives from the RadRibbonBackstage class.

Create class that derives from RadRibbonBackstage

public class CustomBackstage : RadRibbonBackstage 
{ 
} 

Public Class CustomBackstage Inherits RadRibbonBackstage End Class

Override the HandleKey method that comes from the RadRibbonBackstage class and execute your custom logic.

Override the HandleKey method

public class CustomBackstage : RadRibbonBackstage 
{ 
    protected override void HandleKey(KeyEventArgs e) 
    { 
        if (e.Key == Key.Escape  
            && MessageBox.Show("Do you want to close the backstage?", "Confirmation",   MessageBoxButton.YesNo) == MessageBoxResult.Yes) 
        { 
            base.HandleKey(e); 
        } 
    } 
} 
Public Class CustomBackstage 
    Inherits RadRibbonBackstage 
 
    Protected Overrides Sub HandleKey(ByVal e As KeyEventArgs) 
        If e.Key = Key.Escape AndAlso MessageBox.Show("Do you want to close the backstage?",    "Confirmation", MessageBoxButton.YesNo) = MessageBoxResult.Yes Then 
            MyBase.HandleKey(e) 
        End If 
    End Sub 
End Class 
In this article