ToggleButton Class
Namespace: Stride.UI.ControlsAssembly: Stride.UI.dll
Represent a UI toggle button. A toggle but can have two or three states depending on the IsThreeState property.
[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. |
Constructors
ToggleButton()
public ToggleButton()
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> |
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 |
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
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()
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