RadDateTimePicker - SelectAll Text Not Working

2 posts, 1 answers
  1. Abdul
    Abdul avatar
    1 posts
    Member since:
    Feb 2017

    Posted 15 Feb 2017 Link to this post


    I am using RadDateTimePicker (Version 2016.1.328.45) in my WPF application. The requirement is such that I need to select all text inside the DateTimePicker when the user clicks inside it. For this purpose, I am using the GotFocus event, inside which I am getting the TextBox inside the DateTimePicker by the method FindChildByType<TextBox>() and then calling SelectAll() on this TextBox.


    This doesn't work. Any suggestions or workarounds on how to achieve this?


  2. Answer
    Stefan Nenchev
    Stefan Nenchev avatar
    665 posts

    Posted 16 Feb 2017 Link to this post

    Hi Abdul,

    I am here providing the solution I have already sent you in the ticket you have raised as it might be helpful for other users.

    You can handle the PreviewMouseDown event of the DateTimePicker and apply the following logic:
    private void dtPicker_PreviewMouseDown(object sender, MouseButtonEventArgs e)
               if ((e.OriginalSource as UIElement).ParentOfType<RadWatermarkTextBox>() != null)
                  e.Handled = true;
                  (e.OriginalSource as UIElement).ParentOfType<RadWatermarkTextBox>().Focus();

    Stefan Nenchev
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top