public static void OnBindPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ValueWithRangeEditor edit = d as ValueWithRangeEditor; var newPro = e.NewValue as EditorCommon.CustomPropertyDescriptor; foreach (var att in newPro.Attributes) { if (att is EngineNS.Editor.Editor_ValueWithRange) { var valueWithRange = att as EngineNS.Editor.Editor_ValueWithRange; edit.MaxValue = valueWithRange.maxValue; edit.MinValue = valueWithRange.minValue; } } }
public static void OnOutValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ValueWithRangeEditor control = d as ValueWithRangeEditor; if (control.mValueType == null) { if (control.mValueType == typeof(Single) || control.mValueType == typeof(Double)) { BindingOperations.ClearBinding(control.TextBox_Value, TextBox.TextProperty); BindingOperations.SetBinding(control.TextBox_Value, TextBox.TextProperty, new Binding("OutValue") { Source = control, Mode = BindingMode.TwoWay, StringFormat = "0.000", UpdateSourceTrigger = UpdateSourceTrigger.Explicit, }); control.Slider_Value.SmallChange = 0.1; } else { BindingOperations.ClearBinding(control.TextBox_Value, TextBox.TextProperty); BindingOperations.SetBinding(control.TextBox_Value, TextBox.TextProperty, new Binding("OutValue") { Source = control, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.Explicit, }); control.Slider_Value.SmallChange = 1; } control.mValueType = e.NewValue.GetType(); } if (!object.Equals(e.NewValue, control.SliderValue)) { control.SliderValue = System.Convert.ToDouble(e.NewValue); } }