Hi all!
I kindly ask help with databinding my own dependency property.
I have usercontrol where I have slider named "valueSlider". I need to change sliders value from client side using custom dependency property.
My usercontrolside code:
public int SliderCurrentValue
{
get { return (int)GetValue(SliderCurrentValueProperty); }
set { SetValue(SliderCurrentValueProperty, value); }
}
public static readonly DependencyProperty SliderCurrentValueProperty =
DependencyProperty.Register("SliderCurrentValue", typeof(int), typeof(MySliderControl), new UIPropertyMetadata(0, new PropertyChangedCallback(SliderCurrentValueChanged)));
private static void SliderCurrentValueChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs args)
{
MySliderControl c = (MySliderControl)depObj;
c.valueSlider.Value = Convert.ToDouble(args.NewValue);
}
and clientside code where I create databindings between my dataClass and my usercontrol (that slider value)
Binding binding = new Binding("MyIntProperty");
binding.Mode = BindingMode.TwoWay;
binding.Source = myDataClass;
MyUserControl.valueSlider.SetBinding(Slider.ValueProperty, binding);
MyUserControl.SetBinding(MyUserControl.SliderCurrentValue, binding);
The easiest solution is to show all my valueSlider properties to outside like I show above, but I really need to show just its slidervalue.
I hope you got idea :)
Cheers