콘텐츠로 이동

Buttons and toggles markup reference

이 콘텐츠는 아직 번역되지 않았습니다.

Buttons, drop-down buttons, toggles, check boxes, radio buttons, and segmented controls.

Receiver: SegmentedBase and derived types (where T : SegmentedBase).

Method Sets Summary
ItemPadding(Thickness value) ItemPadding Sets the per-segment padding; the strip height follows the control, so use a small value for a compact, icon-only strip.
ItemTemplate(IDataTemplate template) ItemTemplate Sets the segment template.
Items(IReadOnlyList<T> items, Func<T, string> textSelector = null, Func<T, object> keySelector = null) Sets ItemsSource to a view over the items, one segment each, with an optional text selector.
Items(params string[] items) Sets ItemsSource to a view over the strings, one segment each.
ItemsSource(ISelectableItemsView itemsSource) ItemsSource Sets the items source.
Sizing(SegmentSizing value) Sizing Sets how segments are sized along the horizontal axis.

Receiver: ButtonGroup.

Method Sets Summary
ItemTemplate(Func<TemplateContext, FrameworkElement> build, Action<FrameworkElement, TItem, int, TemplateContext> bind, Action<FrameworkElement, TItem, int, TemplateContext> unbind = null) Sets the segment template for a ButtonGroup using delegate-based templating.
ItemTemplate(Func<TemplateContext, TElement> build, Action<TElement, TItem, int, TemplateContext> bind, Action<TElement, TItem, int, TemplateContext> unbind = null) Sets the segment template; the bind callback receives the root the build callback returned.
ItemTemplate(Func<TemplateContext, TElement> build, Action<TElement, TItem> bind) Sets the segment template from a root element and a bind callback that needs only the item.
PrepareContainer(Action<SegmentButton, T, int> prepare) Configures each ButtonGroup segment container after its content is bound. Use it to assign Command, subscribe to Click, or configure IsCheckable / IsChecked (independent toggle), enabled state, or tooltip.

Receiver: DropDownButton.

Method Sets Summary
BindContent(ObservableValue<TSource> source, Func<TSource, string> convert, bool accessKey = true) bind Content Binds the drop-down button content to a converted observable value (creates a centered text label).
BindContent(ObservableValue<string> source, bool accessKey = true) bind Content Binds the drop-down button content to an observable string value (creates a centered text label).
Content(string text, bool accessKey = true) Content Sets the drop-down button content to a centered text label. When accessKey is true (default), “_” prefixes mark access key characters (e.g., “_Export” registers Alt+E).
DropDownMenu(Menu value) DropDownMenu Sets the menu the drop-down opens.
IsDropDownOpen(bool value = true) IsDropDownOpen Sets whether the menu is open.
MaxDropDownHeight(double value) MaxDropDownHeight Sets an upper bound on the menu height; the default is no bound.
OnDropDownClosed(Action handler) event DropDownClosed Subscribes handler to DropDownClosed. Occurs after the menu closed.
OnDropDownOpening(Action handler) event DropDownOpening Subscribes handler to DropDownOpening. Occurs right before the menu opens, so items can be rebuilt.

Receiver: SegmentedControl.

Method Sets Summary
BindSelectedIndex(ObservableValue<TSource> source, Func<TSource, int> convert, Func<int, TSource> convertBack = null) bind SelectedIndex Binds the selected index to a converted observable value (e.g. an enum).
BindSelectedIndex(ObservableValue<int> source) bind SelectedIndex Binds the selected index to an observable value.
ItemTemplate(Func<TemplateContext, FrameworkElement> build, Action<FrameworkElement, TItem, int, TemplateContext> bind, Action<FrameworkElement, TItem, int, TemplateContext> unbind = null) Sets the segment template using delegate-based templating.
ItemTemplate(Func<TemplateContext, TElement> build, Action<TElement, TItem, int, TemplateContext> bind, Action<TElement, TItem, int, TemplateContext> unbind = null) Sets the segment template; the bind callback receives the root the build callback returned.
ItemTemplate(Func<TemplateContext, TElement> build, Action<TElement, TItem> bind) Sets the segment template from a root element and a bind callback that needs only the item.
OnSelectionChanged(Action<object> handler) event SelectionChanged Subscribes handler to SelectionChanged. Occurs when the selected segment changes.
PrepareContainer(Action<SegmentButton, T, int> prepare) Configures each segment container after its content is bound. The callback receives the container, the item, and its index; use it to set or bind any container property (enabled state, tooltip, etc.). Applied on every rebuild.
SelectedIndex(int value) SelectedIndex Sets the selected segment index (-1 means no selection).
SelectedItem(object value) SelectedItem Sets the currently selected item object, or when nothing is selected.

Receiver: Button and derived types (where T : Button).

Method Sets Summary
BindCommand(ObservableValue<Command> source, CommandPresentationMode presentation = None) bind Command Binds the button’s semantic command to an observable value.
BindContent(ObservableValue<Element> source) bind Content Binds the button content element to an observable value.
BindContent(ObservableValue<TSource> source, Func<TSource, Element> convert) bind Content Binds the button content element to a converted observable value.
BindContent(ObservableValue<TSource> source, Func<TSource, string> convert, bool accessKey = true) bind Content Binds the button content to a converted observable value (creates a centered text label).
BindContent(ObservableValue<string> source, bool accessKey = true) bind Content Binds the button content to an observable string value (creates a centered text label).
Command(Command command, CommandPresentationMode presentation = None) Command, CommandPresentationMode Sets the semantic command invoked by the button.
CommandPresentationMode(CommandPresentationMode value) CommandPresentationMode Sets which command presentation parts are used as generated content; the default is None.
Content(string text, bool accessKey = true) Content Sets the button content to a centered text label. When accessKey is true (default), “_” prefixes mark access key characters (e.g., “_Save” registers Alt+S).
OnCanClick(Func<bool> predicate) event CanClick Sets the predicate asked whether the button can be clicked.
OnClick(Action handler) event Click Subscribes handler to Click. Occurs when the button is clicked.
OnDoubleClick(Action handler) event DoubleClick Adds a left-button double click handler.

Receiver: CheckBox and derived types (where T : CheckBox).

Method Sets Summary
BindContent(ObservableValue<TSource> source, Func<TSource, string> convert, bool accessKey = true) bind Content Binds the content to a converted observable text label. When accessKey is true (default), “_” prefixes in the converted text mark access key characters.
BindContent(ObservableValue<string> source, bool accessKey = true) bind Content Binds the content to an observable text label. When accessKey is true (default), “_” prefixes mark access key characters and stay in sync as the source changes.
BindIsChecked(ObservableValue<TSource> source, Func<TSource, bool?> convert, Func<bool?, TSource> convertBack = null) bind IsChecked Binds the checked state to a converted observable value.
BindIsChecked(ObservableValue<bool> source) bind IsChecked Binds the checked state to an observable value.
BindIsChecked(ObservableValue<bool?> source) bind IsChecked Binds the checked state to an observable nullable value.
Check() IsChecked = true Sets IsChecked to true.
Content(string text, bool accessKey = true) Content Sets the content to a text label. When accessKey is true (default), “_” prefixes mark access key characters (e.g., “_Remember me” registers Alt+R).
Indeterminate(bool isIndeterminate = true) Sets IsChecked to null, the indeterminate state.
IsChecked(bool? isChecked = true) IsChecked Sets the checked state; null is indeterminate.
IsThreeState(bool value = true) IsThreeState Sets whether the check box supports the indeterminate state.
OnCheckStateChanged(Action<bool?> handler) event CheckedChanged Adds a CheckedChanged handler that receives the three-state value.
OnCheckedChanged(Action<bool> handler) event CheckedChanged Adds a checked changed event handler.
ThreeState() IsThreeState = true Sets IsThreeState to true.
Uncheck() IsChecked = false Sets IsChecked to false.

Receiver: SegmentButton.

Method Sets Summary
BindCommand(ObservableValue<Command> source) bind Command Binds the semantic command invoked by a segment button.
IsCheckable(bool value = true) IsCheckable Sets whether a mouse click flips IsChecked (independent toggle).
IsChecked(bool value = true) IsChecked Sets the active-fill visual state (selected or toggled-on).
OnCheckedChanged(Action<bool> handler) event CheckedChanged Subscribes handler to CheckedChanged. Occurs when IsChecked flips due to a click (checkable segments only).
OnClick(Action handler) event Click Subscribes handler to Click. Occurs when the segment is activated by a mouse click or keyboard input.

Receiver: ToggleBase and derived types (where T : ToggleBase).

Method Sets Summary
BindContent(ObservableValue<TSource> source, Func<TSource, string> convert, bool accessKey = true) bind Content Binds the content to a converted observable text label. When accessKey is true (default), “_” prefixes in the converted text mark access key characters.
BindContent(ObservableValue<string> source, bool accessKey = true) bind Content Binds the content to an observable text label. When accessKey is true (default), “_” prefixes mark access key characters and stay in sync as the source changes.
Content(string text, bool accessKey = true) Content Sets the content to a text label. When accessKey is true (default), “_” prefixes mark access key characters (e.g., “_Save” registers Alt+S).
IsChecked(bool value = true) IsChecked Sets the checked state.
OnCheckedChanged(Action<bool> handler) event CheckedChanged Subscribes handler to CheckedChanged. Occurs when the checked state changes.

Receiver: RadioButton and derived types (where T : RadioButton).

Method Sets Summary
BindIsChecked(ObservableValue<T> source, Func<T, bool> convert, Func<bool, T> convertBack = null) bind IsChecked Binds the checked state to a converted observable value.
BindIsChecked(ObservableValue<T> source, Func<T, bool> convert, Func<bool, ValueTuple<bool, T>> convertBack) bind IsChecked Binds the checked state to a converted observable value, with a convert-back that can report failure.
BindIsChecked(ObservableValue<bool> source) bind IsChecked Binds the checked state to an observable value.
GroupName(string value) GroupName Sets the group name for mutual exclusion.
OnChecked(Action handler) event Checked Adds a checked event handler.
OnUnchecked(Action handler) event Unchecked Adds an unchecked event handler.

Receiver: RepeatButton and derived types (where T : RepeatButton).

Method Sets Summary
Delay(double value) Delay Sets the delay, in milliseconds, between the initial press and the first repeated click.
Interval(double value) Interval Sets the interval, in milliseconds, between repeated clicks.

Receiver: SplitButton.

Method Sets Summary
BindContent(ObservableValue<TSource> source, Func<TSource, string> convert, bool accessKey = true) bind Content Binds the split button content to a converted observable value (creates a centered text label).
BindContent(ObservableValue<string> source, bool accessKey = true) bind Content Binds the split button content to an observable string value (creates a centered text label).
Content(string text, bool accessKey = true) Content Sets the split button content to a centered text label. When accessKey is true (default), “_” prefixes mark access key characters (e.g., “_Save” registers Alt+S).
DropDownMenu(Menu value) DropDownMenu Sets the menu the drop-down face opens.
IsDropDownOpen(bool value = true) IsDropDownOpen Sets whether the menu is open.
MaxDropDownHeight(double value) MaxDropDownHeight Sets an upper bound on the menu height; the default is no bound.
OnDropDownClosed(Action handler) event DropDownClosed Subscribes handler to DropDownClosed. Occurs after the menu closed.
OnDropDownOpening(Action handler) event DropDownOpening Subscribes handler to DropDownOpening. Occurs right before the menu opens, so items can be rebuilt.

Receiver: ToggleButton.

Method Sets Summary
BindContent(ObservableValue<TSource> source, Func<TSource, string> convert, bool accessKey = true) bind Content Binds the content to a converted observable text label (centered). When accessKey is true (default), “_” prefixes in the converted text mark access key characters.
BindContent(ObservableValue<string> source, bool accessKey = true) bind Content Binds the content to an observable text label (centered). When accessKey is true (default), “_” prefixes mark access key characters and stay in sync as the source changes.
BindIsChecked(ObservableValue<TSource> source, Func<TSource, bool> convert, Func<bool, TSource> convertBack = null) bind IsChecked Binds the checked state to a converted observable value.
BindIsChecked(ObservableValue<bool> source) bind IsChecked Binds the checked state to an observable value.
Content(string text, bool accessKey = true) Content Sets the content to a centered text label. When accessKey is true (default), “_” prefixes mark access key characters.

Receiver: ToggleSwitch.

Method Sets Summary
BindIsChecked(ObservableValue<TSource> source, Func<TSource, bool> convert, Func<bool, TSource> convertBack = null) bind IsChecked Binds the checked state to a converted observable value.
BindIsChecked(ObservableValue<bool> source) bind IsChecked Binds the checked state to an observable value.
ThumbBrush(Color value) ThumbBrush Sets the thumb color.