Populate date in datepicker on hit of F3 button

6 posts, 0 answers
  1. Abdeali
    Abdeali avatar
    3 posts
    Member since:
    Sep 2012

    Posted 11 Sep 2014 Link to this post

    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
  2. Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 12 Sep 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Abdeali
    Abdeali avatar
    3 posts
    Member since:
    Sep 2012

    Posted 12 Sep 2014 in reply to Kalin Link to this post

    Thanks. Yes that would work. Is it possible to do this using triggers from xaml?
  5. Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 16 Sep 2014 Link to this post

    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.
     
  6. Abdeali
    Abdeali avatar
    3 posts
    Member since:
    Sep 2012

    Posted 19 Sep 2014 in reply to Kalin Link to this post

    Thanks for the solution. I actually achieved the F3 shortcut by implementing Behaviors<DatePicker> in my class.
  7. Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 19 Sep 2014 Link to this post

    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.
     
Back to Top
UI for WPF is Visual Studio 2017 Ready