Disable date picker buttons

3 posts, 0 answers
  1. Arthur
    Arthur avatar
    32 posts
    Member since:
    May 2012

    Posted 08 Mar 2013 Link to this post

    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. Masha
    Admin
    Masha avatar
    355 posts

    Posted 12 Mar 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Masha
    Admin
    Masha avatar
    355 posts

    Posted 13 Mar 2013 Link to this post

    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.

Back to Top