Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- <vw:CustomSlider Minimum="1"
- AutoToolTipPlacement="TopLeft"
- AutoToolTipContent="{Binding DateFiltersToolTip}"
- Maximum="{Binding DateFilters.Count}"
- TickFrequency="1"
- TickPlacement="BottomRight"
- HorizontalAlignment="Left"
- SmallChange="1" LargeChange="5"
- Width="200"
- Visibility="Collapsed"
- ValueChanged="Slider_ValueChanged"/>
- */
- public class CustomSlider : Slider
- {
- public object AutoToolTipContent
- {
- get { return GetValue(AutoToolTipContentProperty); }
- set { SetValue(AutoToolTipContentProperty, value); }
- }
- // Using a DependencyProperty as the backing store for AutoToolTip. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty AutoToolTipContentProperty =
- DependencyProperty.Register("AutoToolTipContent", typeof(object), typeof(CustomSlider), new PropertyMetadata(null));
- protected override void OnThumbDragStarted(System.Windows.Controls.Primitives.DragStartedEventArgs e)
- {
- base.OnThumbDragStarted(e);
- AutoToolTipObj.Content = this.AutoToolTipContent;
- }
- protected override void OnThumbDragDelta(System.Windows.Controls.Primitives.DragDeltaEventArgs e)
- {
- base.OnThumbDragDelta(e);
- AutoToolTipObj.Content = this.AutoToolTipContent;
- }
- ToolTip autoToolTipObj;
- public ToolTip AutoToolTipObj
- {
- get
- {
- if (autoToolTipObj == null)
- {
- var fld = typeof(Slider).GetField("_autoToolTip", BindingFlags.NonPublic | BindingFlags.Instance);
- if (fld != null)
- autoToolTipObj = fld.GetValue(this) as ToolTip;
- }
- return autoToolTipObj;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment