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

NavigationBehavior

RadScheduler's NavigationBehavior is responsible for handling the keyboard navigation. The control handles the KeyDown event for the following keys: Tab, PageUp, PageDown, Home, End and all of the arrow keys. The default navigation logic of the control is implemented in the DefaultNavigationBehavior class.

Implementing Custom NavigationBehavior

In order to modify the default NavigationBehavior of the control, you can create a class inheriting DefaultNavigationBehavior. It exposes a single virtual method - Navigate, which is called when one of the navigation keys is pressed. This method receives NavigationData and NavigationDirection parameters. The NavigationData class exposes a property of type ServiceProvider through which you can get information that you might need (such as selected slots and appointments). Example 1 demonstrates how you can prevent the navigation in some scenarios and use the SlotSelectionService.

Example 1: Custom NavigationBehavior

public class CustomNavigationBehavior : DefaultNavigationBehavior 
{ 
    public override void Navigate(NavigationData data, NavigationDirection direction) 
    { 
        // Prevent navigation for the Home key 
        if (direction == NavigationDirection.First) 
        { 
            return; 
        } 
        // Prevent navigation for the End key 
        else if (direction == NavigationDirection.Last) 
        { 
            return; 
        } 
 
         var slotSelectionService = data.ServiceProvider.GetService<SlotSelectionService>(); 
        var currentSlot = slotSelectionService.GetSelection(); 
 
         if(currentSlot != null) 
        { 
            // Prevent navigation to the right, if we have selected the slot for 24th of September 
            if(currentSlot.End.Month == 9 && currentSlot.End.Day == 24 && direction == NavigationDirection.Right) 
            { 
                return; 
            } 
        } 
 
         base.Navigate(data, direction); 
    } 
} 

Example 2: Applying the custom NavigationBehavior

<telerik:RadScheduler> 
    <telerik:RadScheduler.NavigationBehavior> 
        <!-- The namespace "local" refers to the namespace where the CustomNavigationBehavior is defined --> 
        <local:CustomNavigationBehavior /> 
    </telerik:RadScheduler.NavigationBehavior> 
</telerik:RadScheduler> 

See Also

In this article
Not finding the help you need?