Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    ToggleButton Class

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

    Represent a UI toggle button. A toggle but can have two or three states depending on the IsThreeState property.

    System.Object → UIElement → Control → ContentControl → ButtonBase → ToggleButton
    Derived from ToggleButton:

    [DataContract("ToggleButton")]
    [DataContractMetadataType(typeof(ToggleButton.ToggleButtonMetadata))]
    public class ToggleButton : ButtonBase, IUIElementUpdate, IUIElementChildren, IIdentifiable
    Name Description
    Constructors
    ToggleButton()
    Fields
    CheckedEvent

    Identifies the Checked routed event.

    IndeterminateEvent

    Identifies the Indeterminate routed event.

    UncheckedEvent

    Identifies the Unchecked routed event.

    Properties
    CheckedImage

    Gets or sets the image displayed when the button is checked.

    IndeterminateImage

    Gets or sets the image displayed when the button state is undeterminate.

    IsThreeState

    Determines whether the control supports two or three states.

    State

    Gets or sets the state of the ToggleButton

    UncheckedImage

    Gets or sets the image displayed when the button is unchecked.

    Methods
    GoToNextState()

    Move the state of the toggle button to the next state. States order is: Unchecked -> Checked [-> Indeterminate] -> Unchecked -> ...

    OnClick(RoutedEventArgs)
    OnToggleImageInvalidated()

    Function triggered when one of the CheckedImage, IndeterminateImage and UncheckedImage images are invalidated. This function can be overridden in inherited classes.

    Events
    Checked

    Occurs when a ToggleButton is checked.

    Indeterminate

    Occurs when a ToggleButton is Indeterminate.

    Unchecked

    Occurs when a ToggleButton is Unchecked.

    | Improve this Doc View Source

    Constructors


    ToggleButton()

    public ToggleButton()
    | Improve this Doc View Source

    Fields


    CheckedEvent

    Identifies the Checked routed event.

    public static readonly RoutedEvent<RoutedEventArgs> CheckedEvent
    Field Value
    Type Description
    RoutedEvent<RoutedEventArgs>

    IndeterminateEvent

    Identifies the Indeterminate routed event.

    public static readonly RoutedEvent<RoutedEventArgs> IndeterminateEvent
    Field Value
    Type Description
    RoutedEvent<RoutedEventArgs>

    UncheckedEvent

    Identifies the Unchecked routed event.

    public static readonly RoutedEvent<RoutedEventArgs> UncheckedEvent
    Field Value
    Type Description
    RoutedEvent<RoutedEventArgs>
    | Improve this Doc View Source

    Properties


    CheckedImage

    Gets or sets the image displayed when the button is checked.

    [DataMember]
    [Display(null, "Appearance")]
    public ISpriteProvider CheckedImage { get; set; }
    Property Value
    Type Description
    ISpriteProvider

    IndeterminateImage

    Gets or sets the image displayed when the button state is undeterminate.

    [DataMember]
    [Display(null, "Appearance")]
    public ISpriteProvider IndeterminateImage { get; set; }
    Property Value
    Type Description
    ISpriteProvider

    IsThreeState

    Determines whether the control supports two or three states.

    [DataMember]
    [Display(null, "Behavior")]
    public bool IsThreeState { get; set; }
    Property Value
    Type Description
    System.Boolean
    Remarks

    Setting IsThreeState to false changes the State of the toggle button if currently set to Indeterminate


    State

    Gets or sets the state of the ToggleButton

    [DataMember]
    [Display(null, "Behavior")]
    public ToggleState State { get; set; }
    Property Value
    Type Description
    ToggleState
    Remarks

    Setting the state of the toggle button to Indeterminate sets IsThreeState to true.


    UncheckedImage

    Gets or sets the image displayed when the button is unchecked.

    [DataMember]
    [Display(null, "Appearance")]
    public ISpriteProvider UncheckedImage { get; set; }
    Property Value
    Type Description
    ISpriteProvider
    | Improve this Doc View Source

    Methods


    GoToNextState()

    Move the state of the toggle button to the next state. States order is: Unchecked -> Checked [-> Indeterminate] -> Unchecked -> ...

    protected void GoToNextState()

    OnClick(RoutedEventArgs)

    protected override void OnClick(RoutedEventArgs args)
    Parameters
    Type Name Description
    RoutedEventArgs args
    Overrides
    ButtonBase.OnClick(RoutedEventArgs)

    OnToggleImageInvalidated()

    Function triggered when one of the CheckedImage, IndeterminateImage and UncheckedImage images are invalidated. This function can be overridden in inherited classes.

    protected virtual void OnToggleImageInvalidated()
    | Improve this Doc View Source

    Events


    Checked

    Occurs when a ToggleButton is checked.

    public event EventHandler<RoutedEventArgs> Checked
    Event Type
    Type Description
    System.EventHandler<RoutedEventArgs>
    Remarks

    A checked event is bubbling


    Indeterminate

    Occurs when a ToggleButton is Indeterminate.

    public event EventHandler<RoutedEventArgs> Indeterminate
    Event Type
    Type Description
    System.EventHandler<RoutedEventArgs>
    Remarks

    A Indeterminate event is bubbling


    Unchecked

    Occurs when a ToggleButton is Unchecked.

    public event EventHandler<RoutedEventArgs> Unchecked
    Event Type
    Type Description
    System.EventHandler<RoutedEventArgs>
    Remarks

    A Unchecked event is bubbling


    Inherited Members

    ButtonBase.ClickMode
    ButtonBase.IsPressed
    ButtonBase.Click
    ButtonBase.ClickEvent
    ButtonBase.OnTouchDown(TouchEventArgs)
    ButtonBase.OnTouchUp(TouchEventArgs)
    ButtonBase.OnTouchLeave(TouchEventArgs)
    ContentControl.ContentArrangeMatrixPropertyKey
    ContentControl.Content
    ContentControl.VisualContent
    ContentControl.EnumerateChildren()
    ContentControl.MeasureOverride(Vector3)
    ContentControl.ArrangeOverride(Vector3)
    ContentControl.UpdateWorldMatrix(Matrix, Boolean)
    Control.padding
    Control.Padding
    UIElement.InputCategory
    UIElement.PanelCategory
    UIElement.AppearanceCategory
    UIElement.BehaviorCategory
    UIElement.LayoutCategory
    UIElement.MiscCategory
    UIElement.MarginInternal
    UIElement.ArrangeChanged
    UIElement.LocalMatrixChanged
    UIElement.Id
    UIElement.DependencyProperties
    UIElement.LocalMatrix
    UIElement.BackgroundColor
    UIElement.Opacity
    UIElement.Visibility
    UIElement.ClipToBounds
    UIElement.DrawLayerNumber
    UIElement.IsEnabled
    UIElement.CanBeHitByUser
    UIElement.Width
    UIElement.Height
    UIElement.Depth
    UIElement.Size
    UIElement.HorizontalAlignment
    UIElement.VerticalAlignment
    UIElement.DepthAlignment
    UIElement.Margin
    UIElement.MinimumWidth
    UIElement.MinimumHeight
    UIElement.MinimumDepth
    UIElement.MaximumWidth
    UIElement.MaximumHeight
    UIElement.MaximumDepth
    UIElement.DefaultWidth
    UIElement.DefaultHeight
    UIElement.DefaultDepth
    UIElement.Name
    UIElement.DesiredSize
    UIElement.DesiredSizeWithMargins
    UIElement.IsArrangeValid
    UIElement.IsMeasureValid
    UIElement.WorldMatrix
    UIElement.DepthBias
    UIElement.LayoutingContext
    UIElement.VisualChildrenCollection
    UIElement.InvalidateArrange()
    UIElement.InvalidateMeasure()
    UIElement.OnNameChanged()
    UIElement.IsHierarchyEnabled
    UIElement.IsVisible
    UIElement.IsCollapsed
    UIElement.Parent
    UIElement.VisualParent
    UIElement.VisualChildren
    UIElement.HitableChildren
    UIElement.RenderOpacity
    UIElement.RenderSize
    UIElement.RenderOffsets
    UIElement.ActualWidth
    UIElement.ActualHeight
    UIElement.ActualDepth
    UIElement.IUIElementChildren.Children
    UIElement.Measure(Vector3)
    UIElement.Arrange(Vector3, Boolean)
    UIElement.CollapseOverride()
    UIElement.PropagateCollapseToChild(UIElement)
    UIElement.FindName(String)
    UIElement.SetParent(UIElement, UIElement)
    UIElement.SetVisualParent(UIElement, UIElement)
    UIElement.Intersects(Ray, Vector3)
    UIElement.IUIElementUpdate.Update(GameTime)
    UIElement.IUIElementUpdate.UpdateWorldMatrix(Matrix, Boolean)
    UIElement.IUIElementUpdate.UpdateElementState(Int32)
    UIElement.Update(GameTime)
    UIElement.CalculateSizeWithThickness(Vector3, Thickness)
    UIElement.CalculateSizeWithoutThickness(Vector3, Thickness)
    UIElement.CalculateAdjustmentOffsets(Thickness, Vector3, Vector3)
    UIElement.IsTouched
    UIElement.MouseOverState
    UIElement.RequiresMouseOverUpdate
    UIElement.RaiseEvent(RoutedEventArgs)
    UIElement.AddHandler<T>(RoutedEvent<T>, EventHandler<T>, Boolean)
    UIElement.RemoveHandler<T>(RoutedEvent<T>, EventHandler<T>)
    UIElement.MouseOverStateChanged
    UIElement.PreviewTouchDown
    UIElement.PreviewTouchMove
    UIElement.PreviewTouchUp
    UIElement.TouchDown
    UIElement.TouchEnter
    UIElement.TouchLeave
    UIElement.TouchMove
    UIElement.TouchUp
    UIElement.OnPreviewTouchDown(TouchEventArgs)
    UIElement.OnPreviewTouchMove(TouchEventArgs)
    UIElement.OnPreviewTouchUp(TouchEventArgs)
    UIElement.OnTouchEnter(TouchEventArgs)
    UIElement.OnTouchMove(TouchEventArgs)

    Extension Methods

    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    UIElementExtensions.SetPanelZIndex(UIElement, Int32)
    UIElementExtensions.GetPanelZIndex(UIElement)
    UIElementExtensions.SetCanvasRelativeSize(UIElement, Vector3)
    UIElementExtensions.GetCanvasRelativeSize(UIElement)
    UIElementExtensions.SetCanvasRelativePosition(UIElement, Vector3)
    UIElementExtensions.GetCanvasRelativePosition(UIElement)
    UIElementExtensions.SetCanvasAbsolutePosition(UIElement, Vector3)
    UIElementExtensions.GetCanvasAbsolutePosition(UIElement)
    UIElementExtensions.SetCanvasPinOrigin(UIElement, Vector3)
    UIElementExtensions.GetCanvasPinOrigin(UIElement)
    UIElementExtensions.SetGridColumn(UIElement, Int32)
    UIElementExtensions.GetGridColumn(UIElement)
    UIElementExtensions.SetGridRow(UIElement, Int32)
    UIElementExtensions.GetGridRow(UIElement)
    UIElementExtensions.SetGridLayer(UIElement, Int32)
    UIElementExtensions.GetGridLayer(UIElement)
    UIElementExtensions.SetGridColumnSpan(UIElement, Int32)
    UIElementExtensions.GetGridColumnSpan(UIElement)
    UIElementExtensions.SetGridRowSpan(UIElement, Int32)
    UIElementExtensions.GetGridRowSpan(UIElement)
    UIElementExtensions.SetGridLayerSpan(UIElement, Int32)
    UIElementExtensions.GetGridLayerSpan(UIElement)
    VisualTreeHelper.FindVisualChildOfType<T>(UIElement, String)
    VisualTreeHelper.FindVisualChildrenOfType<T>(UIElement)
    VisualTreeHelper.FindVisualParentOfType<T>(UIElement)
    VisualTreeHelper.FindVisualRoot(UIElement)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation