Stride

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

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

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

    Button Class

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

    Represents a Windows button control, which reacts to the Click event.

    System.Object → UIElement → Control → ContentControl → ButtonBase → Button
    Derived from Button: ImageButton

    [DataContract("Button")]
    [DataContractMetadataType(typeof(Button.ButtonMetadata))]
    public class Button : ButtonBase, IUIElementUpdate, IUIElementChildren, IIdentifiable
    Name Description
    Constructors
    Button()
    Properties
    ImageStretchDirection

    Gets or sets a value that indicates how the button image is scaled.

    ImageStretchType

    Gets or sets a value that describes how the button image should be stretched to fill the destination rectangle.

    IsPressed

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

    MouseOverImage

    Gets or sets the image displayed when the mouse hovers over the button.

    NotPressedImage

    Gets or sets the image displayed when the button is not pressed.

    PressedImage

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

    SizeToContent

    Gets or sets whether the size depends on the Content. The default is true.

    Methods
    ArrangeOverride(Vector3)
    MeasureOverride(Vector3)
    OnAspectImageInvalidated()

    Function triggered when one of the PressedImage and NotPressedImage images are invalidated. This function can be overridden in inherited classes.

    | Improve this Doc View Source

    Constructors


    Button()

    public Button()
    | Improve this Doc View Source

    Properties


    ImageStretchDirection

    Gets or sets a value that indicates how the button image is scaled.

    [DataMember]
    [Display(null, "Layout")]
    public StretchDirection ImageStretchDirection { get; set; }
    Property Value
    Type Description
    StretchDirection
    Remarks

    This property has no effect is SizeToContent is true.


    ImageStretchType

    Gets or sets a value that describes how the button image should be stretched to fill the destination rectangle.

    [DataMember]
    [Display(null, "Layout")]
    public StretchType ImageStretchType { get; set; }
    Property Value
    Type Description
    StretchType
    Remarks

    This property has no effect is SizeToContent is true.


    IsPressed

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

    public override bool IsPressed { get; protected set; }
    Property Value
    Type Description
    System.Boolean
    Overrides
    ButtonBase.IsPressed

    MouseOverImage

    Gets or sets the image displayed when the mouse hovers over the button.

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

    NotPressedImage

    Gets or sets the image displayed when the button is not pressed.

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

    PressedImage

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

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

    SizeToContent

    Gets or sets whether the size depends on the Content. The default is true.

    [DataMember]
    [Display(null, "Layout")]
    public bool SizeToContent { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Methods


    ArrangeOverride(Vector3)

    protected override Vector3 ArrangeOverride(Vector3 finalSizeWithoutMargins)
    Parameters
    Type Name Description
    Vector3 finalSizeWithoutMargins
    Returns
    Type Description
    Vector3
    Overrides
    ContentControl.ArrangeOverride(Vector3)

    MeasureOverride(Vector3)

    protected override Vector3 MeasureOverride(Vector3 availableSizeWithoutMargins)
    Parameters
    Type Name Description
    Vector3 availableSizeWithoutMargins
    Returns
    Type Description
    Vector3
    Overrides
    ContentControl.MeasureOverride(Vector3)

    OnAspectImageInvalidated()

    Function triggered when one of the PressedImage and NotPressedImage images are invalidated. This function can be overridden in inherited classes.

    protected virtual void OnAspectImageInvalidated()

    Inherited Members

    ButtonBase.ClickMode
    ButtonBase.Click
    ButtonBase.ClickEvent
    ButtonBase.OnTouchDown(TouchEventArgs)
    ButtonBase.OnTouchUp(TouchEventArgs)
    ButtonBase.OnTouchLeave(TouchEventArgs)
    ButtonBase.OnClick(RoutedEventArgs)
    ContentControl.ContentArrangeMatrixPropertyKey
    ContentControl.Content
    ContentControl.VisualContent
    ContentControl.EnumerateChildren()
    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