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
15
Customizing "Todas" Button in XamDateTimeEditor: set current time
posted

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

Parents
  • 520
    Offline posted

    Hello,

    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;
                }
                else
                {
                    if (nv == DateTime.Now) return;
                    editor.Mask = "{date}";
                    editor.Value = e.NewValue;
                }
            }

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

    Sincerely,
    Tihomir Tonev
    Associate Software Developer
    Infragistics

Reply Children