Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CustomSliderRenderer : SliderRenderer
- {
- /// <summary>
- /// Instantiate a CustomSliderRenderer
- /// </summary>
- /// <param name="context">The context to use</param>
- public CustomSliderRenderer(Context context)
- : base(context) { }
- /// <summary>
- /// Called when the Slider changes
- /// </summary>
- /// <param name="e">The details of the change</param>
- protected override void OnElementChanged(ElementChangedEventArgs<Slider> e)
- {
- base.OnElementChanged(e);
- if (!(e.OldElement is null) || e.NewElement is null)
- return;
- // The line colour to the left of the image
- Control.ProgressTintList = ColorStateList.ValueOf(Color.Black.ToAndroid());
- Control.ProgressTintMode = PorterDuff.Mode.SrcIn;
- // The line colour to the right of the image
- Control.ProgressBackgroundTintList = ColorStateList.ValueOf(Color.Black.ToAndroid());
- Control.ProgressBackgroundTintMode = PorterDuff.Mode.SrcIn;
- }
- /// <summary>
- /// Called when the Slider is layed out.
- /// </summary>
- /// <param name="changed">True if the layout has changed, else false</param>
- /// <param name="left">The left of the Slider</param>
- /// <param name="top">The top of the Slider</param>
- /// <param name="right">The right of the Slider</param>
- /// <param name="bottom">The bottom of the Slider</param>
- protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
- {
- base.OnLayout(changed, left, top, right, bottom);
- if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean && !(Control is null))
- {
- var thumb = Control.Thumb;
- int thumbTop = Control.Height / 2 - thumb.IntrinsicHeight / 2;
- thumb.SetBounds(thumb.Bounds.Left, thumbTop, thumb.Bounds.Left + thumb.IntrinsicWidth, thumbTop + thumb.IntrinsicHeight);
- }
- }
- }
- <Slider
- Grid.Row="7"
- Grid.Column="0"
- Grid.ColumnSpan="2"
- x:Name="DaysAbandonedVisible"
- Value="{Binding DaysAbandonedVisible}"
- Maximum="60"
- Minimum="0"
- ThumbImageSource="Slider.png"/>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement