Table of Contents

Class Slider

Namespace
Stride.UI.Controls
Assembly
Stride.UI.dll

Represents a slider element.

[DataContract("Slider")]
[DataContractMetadataType(typeof(Slider.SliderMetadata))]
[Display(null, "Input")]
public class Slider : UIElement, IUIElementUpdate, IUIElementChildren, IIdentifiable
Inheritance
Slider
Implements
Inherited Members
Extension Methods

Constructors

Slider()

Create a new instance of slider.

public Slider()

Fields

ValueChangedEvent

Identifies the ValueChanged routed event.

public static readonly RoutedEvent<RoutedEventArgs> ValueChangedEvent

Field Value

RoutedEvent<RoutedEventArgs>

Properties

AreTicksDisplayed

Gets or sets the value indicating if the ticks should be displayed or not.

[DataMember]
[Display(null, "Appearance")]
public bool AreTicksDisplayed { get; set; }

Property Value

bool

IsDirectionReversed

Gets or sets the value indicating if the default direction of the slider should reversed or not.

[DataMember]
[Display(null, "Behavior")]
public bool IsDirectionReversed { get; set; }

Property Value

bool

IsTouchedDown

Gets a value that indicates whether the is currently touched down.

protected virtual bool IsTouchedDown { get; set; }

Property Value

bool

Maximum

Gets or sets the greatest possible value of the slider.

[DataMember]
public float Maximum { get; set; }

Property Value

float

Remarks

The value is coerced in the range [Minimum, MaxValue].

Minimum

Gets or sets the smallest possible value of the slider.

[DataMember]
public float Minimum { get; set; }

Property Value

float

Remarks

The value is coerced in the range [MinValue, MaxValue].

MouseOverThumbImage

Gets or sets the image to display as slider thumb (button) when the mouse is over the slider.

[DataMember]
[Display(null, "Appearance")]
public ISpriteProvider MouseOverThumbImage { get; set; }

Property Value

ISpriteProvider

Orientation

Gets or sets the orientation of the slider.

[DataMember]
[Display(null, "Layout")]
public Orientation Orientation { get; set; }

Property Value

Orientation

ShouldSnapToTicks

Gets or sets the value indicating if the slider Value should be snapped to the ticks or not.

[DataMember]
[Display(null, "Behavior")]
public bool ShouldSnapToTicks { get; set; }

Property Value

bool

Step

Gets or sets the step of a Value change.

[DataMember]
[DataMemberRange(0, 3)]
public float Step { get; set; }

Property Value

float

Remarks

The value is coerced in the range [0, MaxValue].

ThumbImage

Gets or sets the image to display as slider thumb (button).

[DataMember]
[Display(null, "Appearance")]
public ISpriteProvider ThumbImage { get; set; }

Property Value

ISpriteProvider

TickFrequency

Gets or sets the frequency of the ticks on the slider track.

[DataMember]
[DataMemberRange(1, 3)]
[Display(null, "Appearance")]
public float TickFrequency { get; set; }

Property Value

float

Remarks

The value is coerced in the range [1, MaxValue].

TickImage

Gets or sets the image to display as tick.

[DataMember]
[Display(null, "Appearance")]
public ISpriteProvider TickImage { get; set; }

Property Value

ISpriteProvider

TickOffset

Gets or sets the offset in virtual pixels between the center of the track and center of the ticks (for an not-stretched slider).

[DataMember]
[DataMemberRange(0, 3)]
[Display(null, "Appearance")]
public float TickOffset { get; set; }

Property Value

float

Remarks

The value is coerced in the range [0, MaxValue].

TrackBackgroundImage

Gets or sets the image to display as Track background.

[DataMember]
[Display(null, "Appearance")]
public ISpriteProvider TrackBackgroundImage { get; set; }

Property Value

ISpriteProvider

TrackForegroundImage

Gets or sets the image to display as Track foreground.

[DataMember]
[Display(null, "Appearance")]
public ISpriteProvider TrackForegroundImage { get; set; }

Property Value

ISpriteProvider

TrackStartingOffsets

Gets or sets the left/right offsets specifying where the track region starts.

[DataMember]
[Display(null, "Appearance")]
public Vector2 TrackStartingOffsets { get; set; }

Property Value

Vector2

Value

Gets or sets the current value of the slider.

[DataMember]
public float Value { get; set; }

Property Value

float

Remarks

The value is coerced in the range [Minimum, Maximum].

Methods

CalculateClosestTick(float)

Calculate the value of the closest tick to the provided value.

protected float CalculateClosestTick(float rawValue)

Parameters

rawValue float

The current raw value

Returns

float

The value adjusted to the closest tick

Decrease()

Decrease the Value by Step.

public void Decrease()

Remarks

If ShouldSnapToTicks is True then it decreases of at least one tick.

Increase()

Increase the Value by Step.

public void Increase()

Remarks

If ShouldSnapToTicks is True then it increases of at least one tick.

MeasureOverride(Vector3)

When overridden in a derived class, measures the size in layout required for possible child elements and determines a size for the UIElement-derived class.

protected override Vector3 MeasureOverride(Vector3 availableSizeWithoutMargins)

Parameters

availableSizeWithoutMargins Vector3

The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available.

Returns

Vector3

The size desired by the children

OnTouchDown(TouchEventArgs)

The class handler of the event TouchDown. This method can be overridden in inherited classes to perform actions common to all instances of a class.

protected override void OnTouchDown(TouchEventArgs args)

Parameters

args TouchEventArgs

The arguments of the event

OnTouchLeave(TouchEventArgs)

The class handler of the event TouchLeave. This method can be overridden in inherited classes to perform actions common to all instances of a class.

protected override void OnTouchLeave(TouchEventArgs args)

Parameters

args TouchEventArgs

The arguments of the event

OnTouchMove(TouchEventArgs)

The class handler of the event TouchMove. This method can be overridden in inherited classes to perform actions common to all instances of a class.

protected override void OnTouchMove(TouchEventArgs args)

Parameters

args TouchEventArgs

The arguments of the event

OnTouchUp(TouchEventArgs)

The class handler of the event TouchUp. This method can be overridden in inherited classes to perform actions common to all instances of a class.

protected override void OnTouchUp(TouchEventArgs args)

Parameters

args TouchEventArgs

The arguments of the event

OnValueChanged(RoutedEventArgs)

The class handler of the event ValueChanged. This method can be overridden in inherited classes to perform actions common to all instances of a class.

protected virtual void OnValueChanged(RoutedEventArgs args)

Parameters

args RoutedEventArgs

The arguments of the event

SetValueFromTouchPosition(Vector3)

Set Value from the world position of a touch event.

protected void SetValueFromTouchPosition(Vector3 touchPostionWorld)

Parameters

touchPostionWorld Vector3

The world position of the touch

SnapToClosestTick()

Snap the current Value to the closest tick.

public void SnapToClosestTick()

Update(GameTime)

Method called by Update(GameTime). This method can be overridden by inherited classes to perform time-based actions. This method is not in charge to recursively call the update on child elements, this is automatically done.

protected override void Update(GameTime time)

Parameters

time GameTime

The current time of the game

Events

ValueChanged

Occurs when the value of the slider changed.

public event EventHandler<RoutedEventArgs> ValueChanged

Event Type

EventHandler<RoutedEventArgs>

Remarks

A ValueChanged event is bubbling