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

RadDateTimePicker - SelectAll Text Not Working

1 Answer 145 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
Abdul
Top achievements
Rank 1
Abdul asked on 15 Feb 2017, 07:47 AM

Hello,

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?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Accepted
Stefan Nenchev
Telerik team
answered on 16 Feb 2017, 10:39 AM
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();
           }
       }

Regards,
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 you to write beautiful native mobile apps using a single shared C# codebase.
Tags
DateTimePicker
Asked by
Abdul
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Share this question
or