public static void ExecuteUpdateStartTime(object sender, ExecutedRoutedEventArgs arg) { TimeCounter myControl = sender as TimeCounter; if (myControl != null) { myControl.StartTime = DateTime.Now; } }
//依赖属性回调事件 private static void OnParameterUpdated(DependencyObject sender, DependencyPropertyChangedEventArgs arg) { TimeCounter myControl = sender as TimeCounter; if (arg.NewValue.GetType() == typeof(int)) { RoutedPropertyChangedEventArgs <int> args = new RoutedPropertyChangedEventArgs <int>((int)arg.OldValue, (int)arg.NewValue, DurationUpdatedEvent); myControl.RaiseEvent(args); } else if (arg.NewValue.GetType() == typeof(DateTime)) { RoutedPropertyChangedEventArgs <DateTime> args = new RoutedPropertyChangedEventArgs <DateTime>((DateTime)arg.OldValue, (DateTime)arg.NewValue, StartTimeUpdatedEvent); myControl.RaiseEvent(args); } }
public static void CanExecuteUpdateStartTime(object sender, CanExecuteRoutedEventArgs arg) { TimeCounter myControl = sender as TimeCounter; arg.CanExecute = (myControl != null); }