Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Customizing "Todas" Button in XamDateTimeEditor: set current time

The "Today" Button only sets the current date. Is there a way to set also the current time by clicking on "Today"?

  • 520
    Offline posted


    Clicking on today button of the XamMonthCalendar selects a date, so one way to achieve what you want would be to hook to the ValueChanged event and configure the editor as per your liking:

     private void XamDateTimeEditor_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
                var nv = (DateTime)e.NewValue;
                var editor = e.Source as XamDateTimeEditor;
                if (nv == DateTime.Today)
                    editor.Mask = "{date} {time}";
                    editor.Value = DateTime.Now;
                    if (nv == DateTime.Now) return;
                    editor.Mask = "{date}";
                    editor.Value = e.NewValue;

    Should you have any further questions, please let me know.

    Tihomir Tonev
    Associate Software Developer

Reply Children