Keyboard Support

RadPropertyGrid allows you to navigate through the items without using the mouse. The keyboard can entirely replace the mouse by allowing you to perform navigation and editing.

Please note that the keyboard navigation is supported only when RadPropertyGrid's property - RenderMode is set to Flat.

Here is the list of the keys that are supported:

  • Tab / Shift + Tab: Navigates through the items.

  • Ctrl + Shift + O: Sorts by OrderIndex and DisplayName.

  • Ctrl + Shift + C: Groups by GroupName.

  • Ctrl + Shift + Space: Expands the field that represents the current property definition.

  • Ctrl + End: Moves to the last field.

  • Ctrl + Home: Moves to the first field.

  • PageDown: Moves a page down.

  • PageUp: Moves a page up.

Custom Keyboard Command Provider

RadPropertyGrid provides an easy MVVM-friendly approach for customization of its default commands logic. If you want to modify the way RadPropertyGrid handles a particular key, you could create your own custom command provider and predefine the behaviour for that key.

The approach for accomplishing the purpose is to create a separate class, inherit PropertyGridCommandProvider and override the ProvideCommandsForKey(KeyEventArgs args) method. In this way, only the undesired behavior can be adjusted according to your requirements.

The class responsible for customizing the keyboard navigation should be similar to the one below:

Example 1: Creating custom command provider

public class CustomKeyboardCommandProvider : PropertyGridCommandProvider 
{ 
    public CustomKeyboardCommandProvider() 
        : base(null) 
    { 
    } 
    public CustomKeyboardCommandProvider(RadPropertyGrid propertyGrid) 
        : base(propertyGrid) 
    { 
        this.PropertyGrid = propertyGrid; 
    } 
    public override List<DelegateCommandWrapper> ProvideCommandsForKey(KeyEventArgs args) 
    { 
        List<DelegateCommandWrapper> actionsToExecute = base.ProvideCommandsForKey(args); 
        if (args.Key == Key.Tab) 
        { 
            actionsToExecute.Clear(); 
            actionsToExecute.Add(new PropertyGridDelegateCommandWrapper(RadPropertyGridCommands.MoveToNext, this.PropertyGrid)); 
            if (!this.PropertyGrid.SelectedPropertyDefinition.IsExpanded) 
            { 
                actionsToExecute.Add(new PropertyGridDelegateCommandWrapper(RadPropertyGridCommands.ExpandCurrentField, this.PropertyGrid)); 
            } 
        } 
        if (args.Key == Key.Tab && Keyboard.Modifiers == ModifierKeys.Shift) 
        { 
            actionsToExecute.Clear(); 
            actionsToExecute.Add(new PropertyGridDelegateCommandWrapper(RadPropertyGridCommands.MoveToPrevious, this.PropertyGrid)); 
            if (!this.PropertyGrid.SelectedPropertyDefinition.IsExpanded) 
            { 
                actionsToExecute.Add(new PropertyGridDelegateCommandWrapper(RadPropertyGridCommands.ExpandCurrentField, this.PropertyGrid)); 
            } 
        } 
        return actionsToExecute; 
    } 
} 
Public Class CustomKeyboardCommandProvider 
    Inherits PropertyGridCommandProvider 
    Public Sub New() 
        MyBase.New(Nothing) 
    End Sub 
    Public Sub New(ByVal propertyGrid As RadPropertyGrid) 
        MyBase.New(propertyGrid) 
        Me.PropertyGrid = propertyGrid 
    End Sub 
    Public Overrides Function ProvideCommandsForKey(ByVal args As KeyEventArgs) As List(Of DelegateCommandWrapper) 
        Dim actionsToExecute As List(Of DelegateCommandWrapper) = MyBase.ProvideCommandsForKey(args) 
        If args.Key = Key.Tab Then 
            actionsToExecute.Clear() 
            actionsToExecute.Add(New PropertyGridDelegateCommandWrapper(RadPropertyGridCommands.MoveToNext, Me.PropertyGrid)) 
            If Not Me.PropertyGrid.SelectedPropertyDefinition.IsExpanded Then 
                actionsToExecute.Add(New PropertyGridDelegateCommandWrapper(RadPropertyGridCommands.ExpandCurrentField, Me.PropertyGrid)) 
            End If 
        End If 
        If args.Key = Key.Tab AndAlso Keyboard.Modifiers = ModifierKeys.Shift Then 
            actionsToExecute.Clear() 
            actionsToExecute.Add(New PropertyGridDelegateCommandWrapper(RadPropertyGridCommands.MoveToPrevious, Me.PropertyGrid)) 
            If Not Me.PropertyGrid.SelectedPropertyDefinition.IsExpanded Then 
                actionsToExecute.Add(New PropertyGridDelegateCommandWrapper(RadPropertyGridCommands.ExpandCurrentField, Me.PropertyGrid)) 
            End If 
        End If 
        Return actionsToExecute 
    End Function 
End Class 

Following up the code-snippet above, a press of Tab/ Shift + Tab keys will result in moving the focus to the property field above/ below and expanding it if possible. However, do not forget to remove the predefined commands for that particular key by calling the Clear() method.

The last thing to be done is to set CommandProvider Property of the RadPropertyGrid to be the newly-created CustomKeyboardCommandProvider class:

Example 2: Defining the custom command provider in XAML

<telerik:RadPropertyGrid x:Name="RadPropertyGrid"> 
    <telerik:RadPropertyGrid.CommandProvider> 
        <my:CustomKeyboardCommandProvider PropertyGrid="{Binding ElementName=PropertyGrid1}" /> 
    </telerik:RadPropertyGrid.CommandProvider> 
</telerik:RadPropertyGrid> 

Example 3: Set the custom command provider to RadPropertyGrid

this.RadPropertyGrid.CommandProvider = new CustomKeyboardCommandProvider(this.RadPropertyGrid); 
Me.RadPropertyGrid.CommandProvider = New CustomKeyboardCommandProvider 

Text Search Navigation

With the R2 2020 release, the RadPropertyGrid allows you to navigate to a specific property by pressing its first letter from the keyboard or starting to type the first couple letters from its name. This functionality is disabled by default. To enable it you need to set the IsTextSearchEnabled property to true.

Searching for a property by typing its first letter requires the RadPropertyGrid control to be focused.

Example 4: Enabling keyboard search navigation

<telerik:RadPropertyGrid x:Name="RadPropertyGrid" IsTextSearchEnabled="True"/> 

Text Search Mode

When the user searches for a property by pressing a letter from the keyboard, the control will select the first property, which starts with the typed letter. This is the default behavior of the text search functionality. This behavior is controlled from the TextSearchMode property of the RadPropertyGrid. The supported modes of this enumeration property are: StartsWith and Contains.

Example 5: Contains Text Search Mode

<telerik:RadPropertyGrid x:Name="RadPropertyGrid" IsTextSearchEnabled="True" TextSearchMode="Contains"/> 

Text Searh With Case Sensitive

By default, text search navigation is case-insensitive. You can make your search case-sensitive by using the IsTextSearchCaseSensitive property.

Example 6: Search with Case-Sensitive

<telerik:RadPropertyGrid x:Name="RadPropertyGrid" IsTextSearchEnabled="True" TextSearchMode="Contains" IsTextSearchCaseSensitive="True"/> 

Text Search Timeout

In a scenario with a larger text for a property name, you may need to increase the time for typing more letters. The keyboard search text navigation functionality allows you to increase the timeout for resetting the typed text. This can be done through the TextSearch.AutoCompleteTimeout static property of the RadPropertyGrid. This property is of type TimeSpan.

Example 8: Increase the timeout for resetting the typed text

public MainWindow() 
{ 
    InitializeComponent(); 
    Telerik.Windows.Controls.TextSearch.AutoCompleteTimeout = new TimeSpan(1500); 
} 

Disabling Navigation

As of Q1 2015 PropertyGridCommandProvider exposes a new property: EnableBuiltInNavigation. By default its value is set to "True". In order to disable the navigation which comes from "Flat" RenderMode, you can set its value to "False".

Example 10: Disabling navigation

public class CustomKeyboardCommandProviderWithoutNavigation : PropertyGridCommandProvider 
{ 
    public CustomKeyboardCommandProviderWithoutNavigation() 
        : base(null) 
    { 
    } 
    public CustomKeyboardCommandProviderWithoutNavigation(RadPropertyGrid propertyGrid) 
        : base(propertyGrid) 
    { 
        this.PropertyGrid = propertyGrid; 
        this.EnableBuiltInNavigation = false; 
    } 
} 
Public Class CustomKeyboardCommandProviderWithoutNavigation 
    Inherits PropertyGridCommandProvider 
    Public Sub New() 
        MyBase.New(Nothing) 
    End Sub 
    Public Sub New(ByVal propertyGrid As RadPropertyGrid) 
        MyBase.New(propertyGrid) 
        Me.PropertyGrid = propertyGrid 
        Me.EnableBuiltInNavigation = False 
    End Sub 
End Class 

See Also

In this article
Not finding the help you need? Improve this article