private static decimal LimitValueByBounds(decimal newValue, SpinnerControl control) { newValue = Math.Max(control.Minimum, Math.Min(control.Maximum, newValue)); // then ensure the number of decimal places is correct. newValue = decimal.Round(newValue, control.DecimalPlaces); return(newValue); }
public static IObservable <double> SelectValueChanges(SpinnerControl spinnerControl) { return(Observable.FromEventPattern < RoutedPropertyChangedEventHandler <decimal>, RoutedPropertyChangedEventArgs <double> >(a => spinnerControl.ValueChanged += a, a => spinnerControl.ValueChanged += a) .Select(a => a.EventArgs.NewValue)); }
protected static void OnIncreaseCommand(object sender, ExecutedRoutedEventArgs e) { SpinnerControl control = sender as SpinnerControl; if (control != null) { control.OnIncrease(); } }