Home Forums WPF controls Xceed DataGrid for WPF DatePicker: Closing the Calendar on "Today" button click

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #23099 |

    Hi

    Not a major issue, but I am wondering why on Live Explorer clicking the Today button on the calendar closes the changing the date to today, but when I place the DatePicker on my page and click today it does not close?

    Are you doing something special on Live Explorer?

    Thanks
    Neil

    Imported from legacy forums. Posted by nmosafi (had 2359 views)

    User (Old forums)
    Member
    Post count: 23064

    Anyone got any feedback on this?
    Thanks

    Imported from legacy forums. Posted by nmosafi (had 3020 views)

    User (Old forums)
    Member
    Post count: 23064

    The following seems to work:

     public partial class MyControl : UserControl

       {

          public MyControl()

          {

     

             InitializeComponent();

     

             dtePicker.CommandBindings.Insert(0,

                 new CommandBinding(DatePickerCommands.SelectToday,

                                    new ExecutedRoutedEventHandler(this.OnGoToToday)));

     

          }

     

          private void OnGoToToday(object sender, ExecutedRoutedEventArgs e)

          {

             dtePicker.SelectedDate = DateTime.Today;

             Mouse.Capture(null);

          }

     

       }

    What we are doing, in essence, is adding a command binding to the SelectToday command and we add it at the top of the list, because WPF will only execute the first command binding it finds. The implementation for that command, in this case, is simply to set the SelectedDate to today and force the dropdown to close.

    Hope this helps.

    Cheers,

    Alex

    Imported from legacy forums. Posted by Alex (had 626 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.