I have an UserControl with DependencyProperty SliderZoom which is a typeof Slider. In my window I have an control who's name is SliderZoom and i want to use binding on it.
Is that even possible? if not how can i achieve something close to this?
Window Code
<local:NewSlider
SliderZoom="{Binding SliderZoom}">
</local:NewSlider>
<Slider x:Name="SliderZoom"
Width="150"
Interval="1"
Maximum="10"
Minimum="0" />
UserControl NewSlider Code
public Slider SliderZoom
{
get { return (Slider)GetValue(ZoomSliderProperty); }
set { SetValue(ZoomSliderProperty, value); }
}
public static readonly DependencyProperty ZoomSliderProperty =
DependencyProperty.Register("SliderZoom", typeof(Slider), typeof(NewTimeSlider),
new PropertyMetadata(OnZoomSliderChanged));
private static void OnZoomSliderChanged(DependencyObject dependencyObject,DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
{
var AdvanceTimeSlider = dependencyObject as NewTimeSlider;
if (AdvanceTimeSlider != null)
{
AdvanceTimeSlider.OnZoomSliderChanged(dependencyPropertyChangedEventArgs);
}
}
private void OnZoomSliderChanged(DependencyPropertyChangedEventArgs e)
{
SliderZoom.ValueChanged += SliderZoom_OnValueChanged;
var _thumb = SliderTimeLine.Template.FindName("Thumb", SliderZoom) as Thumb;
_thumb.DragCompleted += SliderZoom_OnDragCompleted;
_thumb.DragStarted += SliderZoom_OnDragStarted;
}