Skip to main content

Slider Class

NuGet: GHIElectronics.TinyCLR.UI
Assembly: GHIElectronics.TinyCLR.UI
Namespace: GHIElectronics.TinyCLR.UI.Controls

Horizontal or vertical value slider with optional tick marks and snap-to intervals. The knob is rendered with the shared Scale9 Button bitmaps so it picks up the theme's surface styling automatically.

public class Slider : ContentControl, IDisposable

Constructors

Slider()

public Slider() : this(0, 0)

Initializes a new slider with default size.

Slider(int width, int height)

public Slider(int width, int height)

Initializes a new slider with the given width and height.

Properties

Alpha

public ushort Alpha { get; set; }

The opacity applied when rendering the knob.

RadiusBorder

public int RadiusBorder { get; set; }

Corner radius in pixels for the Scale9-rendered knob.

Orientation

public Orientation Orientation { get; set; }

Whether the slider is laid out horizontally or vertically.

Minimum

public double Minimum { get; set; }

The minimum value the slider can represent.

Maximum

public double Maximum { get; set; }

The maximum value the slider can represent.

Value

public double Value { get; set; }

The current slider value, clamped between Minimum and Maximum.

KnobSize

public int KnobSize { get; set; }

Knob size along the slide axis (px).

TickInterval

public int TickInterval { get; set; }

Number of tick mark intervals along the track. 0 disables ticks.

SnapInterval

public int SnapInterval { get; set; }

Number of snap stops along the track. 0 disables snap (continuous).

TrackColor

public Media.Color TrackColor { get; set; }

Color used for the track line and tick marks.

Methods

OnRender(DrawingContext dc)

public override void OnRender(DrawingContext dc)

Renders the track, tick marks, and knob for the slider.

OnTouchDown(TouchEventArgs e)

protected override void OnTouchDown(TouchEventArgs e)

Begins dragging the knob when the slider is touched.

OnTouchUp(TouchEventArgs e)

protected override void OnTouchUp(TouchEventArgs e)

Ends knob dragging when the touch is released.

OnTouchMove(TouchEventArgs e)

protected override void OnTouchMove(TouchEventArgs e)

Updates the value as the knob is dragged.

OnButtonDown(ButtonEventArgs e)

protected override void OnButtonDown(ButtonEventArgs e)

Hardware button support: Left/Right step a horizontal slider, Up/Down step a vertical slider. Step size is one snap interval, or 1% of the range when SnapInterval is 0.

Dispose()

public void Dispose()

Releases the knob bitmap resources used by the slider.

Dispose(bool disposing)

protected virtual void Dispose(bool disposing)

Releases the knob bitmap resources used by the slider.

Events

ValueChanged

public event ValueChangedEventHandler ValueChanged

Raised when the slider value changes.