1

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.

Grant Winney
  • 65,241
  • 13
  • 115
  • 165
Pranjal Kothari
  • 88
  • 1
  • 10

5 Answers5

2

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;
}
Sourabh
  • 66
  • 6
1

There is an easy solution to this problem.

Adding the property EnableTyping="false" prevents the user from typing.

<telerik:RadDatePicker runat="server" ID="rdpPreviousDay" EnableTyping="false"></telerik:RadDatePicker>
Zoe
  • 27,060
  • 21
  • 118
  • 148
0

Subscribe to the KeyDown event:

<telerik:RadDatePicker KeyDown="StartDate_OnKeyDown" />

And then "handle" all keys, which effectively disables the user from typing anything:

private void StartDate_OnKeyDown(object sender, KeyEventArgs e)
{
    e.Handled = true;
}

Interestingly, there's an IsReadOnly property on the RadDatePicker, which disables the DatePickerTextBox and still allows the user to view the calendar, but unfortunately it also prevents the user from actually making a selection in the calendar. It makes it look like you can select a date, but then it doesn't actually set the SelectedDate property.

Grant Winney
  • 65,241
  • 13
  • 115
  • 165
0

Set the IsHitTestVisible=False, problem solved.

    <telerik:RadDatePicker                          
    SelectedDate="{Binding ValidFrom,Mode=TwoWay}" >
                <telerik:RadDatePicker.Resources>
                    <Style TargetType="telerik:RadWatermarkTextBox">
                        <Setter Property="IsHitTestVisible" Value="False" />                          
                    </Style>
                </telerik:RadDatePicker.Resources>

-1

There is a property DateInput-ReadOnly. Set it to true and you should be good to go.

Patrick Mevzek
  • 10,995
  • 16
  • 38
  • 54