ToggleSplitButton
最后更新于
最后更新于
The ToggleSplitButton
functions as a ToggleButton
with primary and secondary parts that can each be pressed separately. The primary part behaves like a normal ToggleButton
and the secondary part opens a Flyout
with additional actions.
The ToggleSplitButton
has only two states: checked and unchecked. Indeterminate is not supported like it is with a standard ToggleButton
. This was done intentionally to match WinUI and restricts the control’s usage. The ToggleSplitButton
should only be used to turn features on/off. Anything other than that is currently considered poor practice from a usability standpoint.
A ToggleSplitButton
is a fairly specialized control and its usage should be restricted to where it makes clear sense from a user-standpoint. It is intended to turn a feature on/off while allowing some additional configurations to be specified rather than the default.
Like a SplitButton
, the most common action should be the default and what is shown in the primary part. However, unlike the SplitButton
, pressing the primary part will turn this feature on or off instead of simply invoking an action. Additional configurations for the feature should be added to the Flyout
which is shown when the secondary (drop down) part is pressed.
Pressing a configuration in the Flyout
should either (1) turn on the feature with the selected configuration, or (2) change the feature to the selected configuration. Pressing a configuration in the Flyout
should never turn off the feature – that can only be done by toggling the primary part.
Property | Description |
---|---|
Pseudoclass | Description |
---|---|
SplitButton (Flyout closed, unchecked)
SplitButton (Flyout closed, checked)
SplitButton (Flyout opened, checked)
Continuing the text editor example from SplitButton
, a common use case of the ToggleSplitButton
is to add bulleted/numbered lists to text. In this example the primary part will toggle the list on/off while the secondary part will open a Flyout
and allow selecting the bullet or number style.
Sample of ToggleSplitButton for toggle text lists on and off and selecting the list format
Content
The content to display in the primary part
Flyout
The Flyout
which shows up when the secondary part is clicked
Command
A command to be invoked when the primary button is clicked
IsChecked
Gets or sets if the ToggleSplitButton
is checked
:pressed
Set when the entire ToggleSplitButton
is pressed using a keyboard input such as Space or Enter. In this state no distinction is made between primary or secondary parts
:flyout-open
Set when the Flyout
is open
:checked
Set when the ToggleSplitButton
is checked. (IsChecked="true"
)