Implements the toggle switch value, mouse and keyboard interaction, thumb layout, and state-transition animation.
Definition
Namespace:Telerik.WinControls.UI
Assembly:Telerik.WinControls.UI.dll
Syntax:
public class RadToggleSwitchElement : LightVisualElement, INotifyPropertyChanged, ICustomTypeDescriptor, ISupportSystemSkin, IBindableComponent, IComponent, IDisposable, ISupportDrag, ISupportDrop, IShortcutProvider, IStylableElement, IStylableNode, IPrimitiveElement, IShapedElement, IFillElement, IBorderElement, IBoxStyle, IBoxElement, IDrawFillElement, IImageElement, ITextPrimitive, ITextProvider
Inheritance: objectDisposableObjectRadObjectRadElementVisualElementRadComponentElementRadItemUIItemBaseLightVisualElementRadToggleSwitchElement...
Implements:
Inherited Members
Constructors
public RadToggleSwitchElement()
Fields
Identifies the IsOn dependency property.
public static RadProperty IsOnProperty
Identifies the ThumbOffset dependency property.
public static RadProperty ThumbOffsetProperty
Identifies the ThumbTickness dependency property.
public static RadProperty ThumbTicknessProperty
Properties
Gets or sets a value indicating whether animation effects are used when the toggle switch changes state.
public bool AllowAnimation { get; set; }
Gets or sets the total number of animation frames used during state transitions.
public int AnimationFrames { get; set; }
Gets or sets the time interval in milliseconds between animation frames during state transitions.
public int AnimationInterval { get; set; }
Gets or sets the size of the drag threshold area that determines when a mouse operation is considered a drag versus a click.
public int DragSize { get; set; }
Gets a value indicating whether the toggle switch is currently performing an animation transition.
[Browsable(false)]
public bool IsAnimating { get; set; }
Gets a value indicating whether the toggle switch is currently in the "On" state.
public bool IsOn { get; }
Gets the visual element that represents the "Off" state of the toggle switch.
public ToggleSwitchPartElement OffElement { get; protected set; }
Gets or sets the text displayed on the toggle switch when it is in the "Off" state.
public string OffText { get; set; }
Gets the visual element that represents the "On" state of the toggle switch.
public ToggleSwitchPartElement OnElement { get; protected set; }
Gets or sets the text displayed on the toggle switch when it is in the "On" state.
public string OnText { get; set; }
Gets or sets a value indicating whether the toggle switch value can be modified by user interaction.
public bool ReadOnly { get; set; }
Gets or sets the elasticity factor that determines how far the thumb must be dragged before the switch changes state.
public double SwitchElasticity { get; set; }
Gets the movable thumb element that indicates the current state of the toggle switch.
public ToggleSwitchThumbElement Thumb { get; protected set; }
Gets or sets the horizontal offset position of the thumb element within the toggle switch.
public int ThumbOffset { get; set; }
Gets or sets the width of the thumb element in pixels.
[VsbBrowsable(true)]
public int ThumbTickness { get; set; }
Gets or sets the mode that determines how the toggle switch responds to mouse interactions such as clicks and drag operations.
public ToggleStateMode ToggleStateMode { get; set; }
Methods
Cancels the currently running animation.
public void CancelAnimation()
Creates and initializes the child elements that make up the toggle switch visual structure.
protected override void CreateChildElements()
Overrides:
Creates and returns a new instance of a toggle switch part element.
protected virtual ToggleSwitchPartElement CreatePartElement()
A new ToggleSwitchPartElement instance.
Creates and returns a new instance of the thumb element used for user interaction.
protected virtual ToggleSwitchThumbElement CreateThumbElement()
A new ToggleSwitchThumbElement instance.
Releases the managed resources used by the RadToggleSwitchElement.
protected override void DisposeManagedResources()
Overrides:
Calculates the interior area remaining after the element's padding and border are removed.
protected override RectangleF GetClientRectangle(SizeF finalSize)
The arranged size from which to calculate the interior area.
Returns:The padded and bordered client rectangle, with non-negative dimensions.
Overrides:
Returns the element bounds used to clip its child visuals.
Initializes the default field values for the RadToggleSwitchElement.
protected override void InitializeFields()
Overrides:
Raises AnimationFinished when a thumb transition completes.
protected virtual void OnAnimationFinished(AnimationStatusEventArgs e)
The animation status data.
Raises AnimationStarted when a thumb transition begins.
protected virtual void OnAnimationStarted(AnimationStatusEventArgs e)
The animation status data.
Maps Space to toggle, arrow keys to On or Off, and reverses horizontal direction for right-to-left layouts.
protected override void OnKeyDown(KeyEventArgs e)
The key data for the pressed key.
Overrides:
Begins a left-button interaction, stopping an active animation and recording the pointer and thumb positions.
protected override void OnMouseDown(MouseEventArgs e)
The mouse-button and location data for the press.
Overrides:
In drag-capable modes, moves the thumb after the pointer crosses the configured drag threshold.
protected override void OnMouseMove(MouseEventArgs e)
The current mouse-button and pointer-location data.
Overrides:
Completes a click or drag interaction and resolves a dragged thumb to the state selected by SwitchElasticity.
protected override void OnMouseUp(MouseEventArgs e)
The mouse-button and location data for the release.
Overrides:
Raises ValueChanged after an accepted value change.
protected virtual void OnValueChanged()
Raises ValueChanging before committing a new value, allowing handlers to cancel the change.
protected virtual void OnValueChanging(ValueChangingEventArgs e)
The proposed value and cancellation state.
Suppresses the base element border because the switch paints its separate BorderPrimitive child.
Animates the thumb toward the endpoint that represents the current Value, starting from its current offset.
protected virtual void ProcessAnimation()
Sets the value of RadToggleSwitch.
Toggles the value of RadToggleSwitch
public void Toggle()
Toggles the value of RadToggleSwitch
Events
Occurs when an animation transition completes.
public event AnimationFinishedEventHandler AnimationFinished
Occurs when an animation transition starts.
public event AnimationStartedEventHandler AnimationStarted
Occurs after the value of the toggle switch has changed.
public event EventHandler ValueChanged
Occurs before the value of the toggle switch changes and allows the change to be cancelled.
public event ValueChangingEventHandler ValueChanging