private static void UpdateNewValue(UIDateTimeSingle UIDateTimeCtrl) { if (UIDateTimeCtrl != null) { DateTime dValue = (DateTime)UIDateTimeCtrl.GetValue(DateValueProperty); string hValue = (string)UIDateTimeCtrl.GetValue(HourValueProperty); string mValue = (string)UIDateTimeCtrl.GetValue(MinitValueProperty); hValue = hValue == null ? "00" : hValue; mValue = mValue == null ? "00" : mValue; if (DateTime.TryParse(dValue.ToString("yyyy-MM-dd") + " " + hValue + ":" + mValue, out dValue)) { } UIDateTimeCtrl.SetValue(DateTimeValueProperty, dValue); } }
private static void DateTimeValueChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { DateTime dtNew = DateTime.Now; string newValue = e.NewValue == null ? "" : e.NewValue.ToString(); if (DateTime.TryParse(newValue.ToString(), out dtNew)) { } UIDateTimeSingle thisDateTime = d as UIDateTimeSingle; string hor = dtNew.Hour.ToString().PadLeft(2, '0'); string minit = dtNew.Minute.ToString().PadLeft(2, '0'); thisDateTime.SetValue(DateValueProperty, dtNew); thisDateTime.SetValue(HourValueProperty, hor); thisDateTime.SetValue(MinitValueProperty, minit); if (thisDateTime.DataChanged != null) { thisDateTime.DataChanged(thisDateTime, (DateTime)thisDateTime.GetValue(DateValueProperty)); } }