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

Populate date in datepicker on hit of F3 button

5 Answers 77 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
Abdeali
Top achievements
Rank 1
Abdeali asked on 11 Sep 2014, 01:43 PM
Hello,

I need to Populate current date in my telerik datepicker control as soon as i hit F3 key. How can i achieve this in wpf telerik datepicker?

Thanks,

Abdi

5 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 12 Sep 2014, 07:47 AM
Hello Abdi,

You can set the current date of the control by setting the DisplayDate of the Calendar located inside of the Template of the DatePicker. What you can do is to hook to the KeyUp event of the DatePicker, in the handler you can find the Calendar in the Template and set its DisplayDate property as desired whenever the F3 button is clicked. Please check the following code snippet and let me know if it helps as I'm not complete sure if this was the exact requirement:

private void RadDatePicker_KeyUp(object sender, KeyEventArgs e)
{
    if (e.Key == Key.F3)
    {
        var calendar = this.DatePicker.Template.FindName("PART_Calendar", this.DatePicker) as RadCalendar;
        calendar.DisplayDate = new DateTime(2015, 1, 1);
    }
}

Hope this will work for you.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Abdeali
Top achievements
Rank 1
answered on 12 Sep 2014, 12:12 PM
Thanks. Yes that would work. Is it possible to do this using triggers from xaml?
0
Kalin
Telerik team
answered on 16 Sep 2014, 12:35 PM
Hello Abdeali,

You can easily achieve the desired by using a KeyBinding to F3 key and execute a custom Command. Actually the DatePicker also provides DisplayDate property which can be bound to a property in the ViewModel, so whenever the Command is executed you would be able to change the property as desired. Please check the attached sample project which demonstrates the explained above.

Hope this helps.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Abdeali
Top achievements
Rank 1
answered on 19 Sep 2014, 10:39 AM
Thanks for the solution. I actually achieved the F3 shortcut by implementing Behaviors<DatePicker> in my class.
0
Kalin
Telerik team
answered on 19 Sep 2014, 11:19 AM
Hi Abdeali,

I'm glad you have managed to achieve the desired. If you have any other questions or issues, let us know.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
DatePicker
Asked by
Abdeali
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Abdeali
Top achievements
Rank 1
Share this question
or