This is a migrated thread and some comments may be shown as answers.

Disable date picker buttons

2 Answers 270 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
Arthur
Top achievements
Rank 1
Arthur asked on 08 Mar 2013, 03:59 PM
I have set the DatePicker to IsReadOnly=true, which stops users from typing in the control.

However, the show calendar button is still active.

How do I disable this?


Thanks

2 Answers, 1 is accepted

Sort by
0
Masha
Telerik team
answered on 12 Mar 2013, 05:08 PM
Hi Arthur,

You will need to either customize the Template of the control and set the IsReadOnly property of the RadWatermarkTextBox to true or use the Loaded event of the control and set it in the code behind.

The next code snippet shows how the Loaded event should look like:
in the xaml:
<telerik:RadDatePicker Loaded="DatePicker_Loaded_1"/>

and in the code behind:
private void DatePicker_Loaded_1(object sender, RoutedEventArgs e)
{
    var datePicker = sender as RadDatePicker;
    var datePickerTextBox = datePicker.ChildrenOfType<RadWatermarkTextBox>().FirstOrDefault() as RadWatermarkTextBox;
    datePickerTextBox.IsReadOnly = true;
}

Hope this helps.

Greetings,
Maria
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Masha
Telerik team
answered on 13 Mar 2013, 08:21 AM
Hello Arthur,

I've missed to add another solution to your question.
You could easily disable RadDateTimePicker by setting IsEnabled property to false.
The approach described below prevents user from typing but he still can select the date from the calendar.

I hope this will be helpful.

Greetings,
Maria
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
DatePicker
Asked by
Arthur
Top achievements
Rank 1
Answers by
Masha
Telerik team
Share this question
or