How to show tick marks in Xamarin forms slider control

xamarin forms range slider
xamarin forms slider drag completed
image slider in xamarin forms
xamarin slider minimum value
xamarin forms slide view
xaml slider
xamarin forms slider text
xamarin-forms slider github

I am using Xamarin forms Slider control in portable project.This is correctly showing minimum, maximum values.But i want to show tick marks in this control so that user can know number of steps.

This solutions supports Android as well as ios. Below is the control I am using:-

<Slider x:Name="slider" HorizontalOptions="FillAndExpand"
                    Maximum="{Binding Maximum}"
                    Minimum="{Binding Minimum}" />

Can someone help me with links or code snippets ?

So I finally ended with this solution for Android:-

protected override void OnElementChanged(ElementChangedEventArgs<Slider> e)
        {
            base.OnElementChanged(e);

            if (this.Control != null)
            {
                var slider = (MySlider)this.Element;

                this.Control.TickMark = Resources.GetDrawable(Resource.Drawable.Icon);//works by setting whole slider image
                //this.Control.SetThumb(Resources.GetDrawable(Resource.Drawable.Icon));//works by setting thumbnail movable image

                Control.Max = (int)(slider.Maximum - slider.Minimum);//shows RHS value plus one
                Control.Progress = (int)slider.Value;
            }
        }

Ticks Customization in Xamarin Range Slider control, Learn about Ticks Customization support in Syncfusion Xamarin Range Slider (​SfRangeSlider) control and more details. TickPlacement. The TickPlacement property determines where to draw tick marks in relation to the track. Available Tick has been placed at the bottom right of SfRangeSlider in Xamarin.Forms  Step 4:Set Stack view orientation based on slider orientation. If the slider is horizontal add stack orientation horizontal. This stack view will contain the tick marks behind the slider. stack. Orientation = StackOrientation. Horizontal; Step 5: Add the method to get the buffer offset based on thumb size and tick width.

The slider which comes with Xamarin.Forms doesn't have any tick marks. Basically you have three options:

1) Make a custom Xamarin Forms View with a grid that holds the slider and several BoxViews forming your tick marks and expose the needed values as BindableProperties. Pro: Can be done quite fast, no need for custom renderers Con: Not the most elegant solution

2) Make a custom renderer, rendering the slider the way you want it. Pro: Better solution, since you only need to add your custom slider to the view Con: You need to create a custom renderer for each target platform handling the drawing of the tick marks

3) Look for a suitable component or a nuGet Package that contains a slider suitable for your needs

How to add tick marks on sliders in Xamarin Forms, This stack view will contain the tick marks behind the slider. stack.Orientation = StackOrientation.Horizontal; Step 5: Add the method  Ticks Customization in Xamarin Range Slider (SfRangeSlider) Tick marks can be placed along the track in a uniform manner or it’s position can also be customized. TickPlacement. The TickPlacement property determines where to draw tick marks in relation to the track. Available options for this property are,

You can try this for xamarin forms slider with ticks

https://xamarinexperience.blogspot.com/2019/03/how-to-add-tick-marks-on-sliders-in.html

Slider.Ticks Property (System.Windows.Controls), Forms Slider is a horizontal bar that can be manipulated by the user to shows show to create a Slider and two Label objects in code: C# Copy. This article demonstrates how to create and use a Customize Slider control in Xamarin.Forms, XAML, and C#. This article starts with the introduction of the Customize Slider tag in XAML. After that, it demonstrates how to set BorderColor, BorderWidth, CornerRadius, and IsCurvedEnabled of a Custom Entry.

Xamarin.Forms Slider, I have a simple slider on my xaml <Slider x:Name="DesSlider" private void SetStepFrequency() { if (Control != null) { Control. To use it in your view (ctrlEx is corresponding to the namespace of your PCL SliderEx class) /2019/03/how-​to-add-tick-marks-on-sliders-in.html " which has step by step tutorial  Xamarin.Forms Range Slider control. A single slider can be used either as a vertical or horizontal slider. A single value or a range can be selected by providing a single thumb or two thumbs, respectively. Customizing ticks, thumbs, and tracking can easily adapt the control to your app’s design.

How to add steps to my slider?, As you can see, xaml structure is very simple, just the regular slider and a stacklayout above it where we will add the labels for the steps. binding properties, bindingcontext and lifecycle events to take control of everything. How to add steps to my slider? 2019/03/how-to-add-tick-marks-on-sliders-in.html " which has step by step tutorial on how to add ticks to slider in xamarin forms

Syncfusion.Xamarin.SfRangeSlider 18.1.0.45, NET WebForms · C# · CSS3 · HTML5 · jQuery · PHP5. Misc. controls: The Slider control. The Slider control allows you to pick a numeric value by dragging a thumb a look at the screenshot above, you will see that the thumb is between ticks. In the XAML part of the code, we have three DockPanels, each with a Label,  1.)How to create custom slider in xamarin forms. 2.)Slider Customization — Xamarin Forums 3.)Customizing Xamarin.Forms Controls with Effects 4.)Slider Control In Xamarin.Forms 5.)Advanced

Comments
  • Hi @Markus, I am trying by adding custom renderer for android. But not able to assign value/shape to tickmark. Below is my code:- protected override void OnElementChanged(ElementChangedEventArgs<Slider> e) { base.OnElementChanged(e); if (this.Control != null) { var slider = (MySlider)this.Element; //this.Control.TickMark -- how to add ? } } }
  • ok I got to set TickMark using below line:- this.Control.TickMark = Resources.GetDrawable(Resource.Drawable.Icon); But this doesn't show marks for all steps. I want to show small vertical marks on every step so that user can get a feel of how many steps are present and in how much duration.