Search code examples
c#wpftelerikraddatepicker

How to disable manual input in a Telerik RadDatePicker


I am using a Telerik RadDatePicker, and I want to disable input by the user, but they should be able to select from the calender.

<telerik:RadDatePicker Culture="{Binding GetLanguage}" x:Name="startDate" 
                       Margin="0,5,0,5" HorizontalAlignment="Left"
                       VerticalAlignment="Center" Grid.Column="1" TabIndex="2"
                       MinWidth="120" Width="120" Height="Auto" MaxHeight="25"
                       KeyDown="filterDate_KeyDown" >
</telerik:RadDatePicker>

I have used KeyDown but it did not help.


Solution

  • The PreviewKeyDown event exists exactly for this sort of thing.

    private void spacebarHandler_PreviewKeyDown(object sender, KeyEventArgs e)
     {
    if (e.Key == Key.Space)
        e.Handled = true;
    }