Slider ThumImage hides on Maximum value

mayankkarkimayankkarki Member ✭✭
edited October 11 in Xamarin.Forms

In UWP, I am using slider control and setting triangle as thumb image. On extreme left or minimum value, image shows correctly. But on dragging it to maximum values it hides out on maximum value.
<Slider.ThumbImageSource> <OnPlatform x:TypeArguments="FileImageSource"> <On Platform="UWP" Value="Assets/Images/Triangle.png"/> </OnPlatform> </Slider.ThumbImageSource>

Best Answer

Answers

  • mayankkarkimayankkarki Member ✭✭

    Thanks, I checked the solution and that's exactly my requirement. But I am using slider control on portable code rather than uwp code. I have to share same code among android and ios also. But I am also trying to use SliderRenderer class to do platform specific changes.

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    Yes, you can use Custom renderer to achieve it for specific platform.

    You can create it like following code.

      [assembly: ExportRenderer(typeof(CustomSlider), typeof(CustomSliderRenderer))]
     namespace ForteMultiplataform.UWP
     {   
    public class CustomSliderRenderer : SliderRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Slider> e)
        {
            base.OnElementChanged(e);
    
            if (e.NewElement != null)
            {
                Windows.UI.Xaml.Style sliderStyle = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["xxxxxstyle"];
                Control.Style = sliderStyle;
            }
        }
    }
    }
    
  • mayankkarkimayankkarki Member ✭✭

    Thanks, Using App.Current.Resources, I managed to set the slider style for uwp platform.

Sign In or Register to comment.