ButtonBase Class
public abstract class ButtonBase : ControlBase, IKeyTipTarget, ILogicalParent, IVariantControl- Inheritance:
- object Visual UIElement FrameworkElement Control ControlBase object
- Derived:
- Button CheckBox PopupButtonBase RadioButton Tab
- Implements:
- IKeyTipTarget ILogicalParent IVariantControl
Constructors
ButtonBase()
Initializes an instance of the class.
protected ButtonBase()Properties
ClickMode
Gets or sets when the Click event should occur.
public ClickMode ClickMode { get; set; }Property Value
HasPopup
Gets whether the control has a popup.
public bool HasPopup { get; protected set; }Property Value
- bool:
- trueif the control has a popup; otherwise,- false.
ImageSourceSmallSize
Gets or sets the size of the ImageSourceSmall when used in a VariantSize.Collapsed button template.
public Size ImageSourceSmallSize { get; set; }Property Value
- Size:
- The size of the ImageSourceSmall when used in a - VariantSize.Collapsedbutton template. The default value is- 16x16.
InputGestureText
Gets or sets the input gesture text (keyboard shortcut) to display when used in a small menu item context.
[Localizability(LocalizationCategory.None)]
public string InputGestureText { get; set; }Property Value
- string:
- The input gesture text (keyboard shortcut) to display when used in a small menu item context. 
IsChecked
Gets or sets whether the control is checked.
public bool? IsChecked { get; set; }Property Value
- bool?:
- trueif the control is checked; otherwise,- false. The default value is- false.
IsEnabledCore
Gets a value that becomes the return value of IsEnabled in derived classes.
protected override bool IsEnabledCore { get; }Property Value
- bool:
- trueif the element is enabled; otherwise,- false.
IsPointerOver
Gets whether the mouse is truly over the control, which works around an issue in WPF where taps on controls retain the mouse over state.
public bool IsPointerOver { get; }Property Value
- bool:
- trueif the mouse is truly over the control; otherwise,- false.
IsPressed
Gets whether the button is pressed.
public bool IsPressed { get; }Property Value
- bool:
- trueif the button is pressed; otherwise,- false.
MenuItemDescription
Gets or sets the description that can be used on buttons in a large menu item context.
[Localizability(LocalizationCategory.Text)]
public string MenuItemDescription { get; set; }Property Value
- string:
- The description that can be used on buttons in a large menu item context. 
StaysOpenOnClick
Gets or sets whether the control keeps a parent popup open when it is clicked.
public bool StaysOpenOnClick { get; set; }Property Value
- bool:
- trueif the parent popup remains open when the control is clicked; otherwise,- false.
Methods
MeasureOverride(Size)
When overridden in a derived class, measures the size in layout required for child elements and determines a size for the FrameworkElement-derived class.
protected override Size MeasureOverride(Size constraint)| Parameter | Type | Description | 
|---|---|---|
| constraint | Size | The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available. | 
Returns
- Size:
- The size that this element determines it needs during layout, based on its calculations of child element sizes. 
OnChecked()
Raises the CheckedEvent.
protected virtual void OnChecked()OnClick(ExecuteRoutedEventArgs)
Called when the control is clicked and a Click event is raised.
protected override void OnClick(ExecuteRoutedEventArgs e)| Parameter | Type | Description | 
|---|---|---|
| e | ExecuteRoutedEventArgs | An  | 
OnCommandChanged(ICommand, ICommand)
Occurs when the Command property has changed.
protected override void OnCommandChanged(ICommand oldCommand, ICommand newCommand)| Parameter | Type | Description | 
|---|---|---|
| oldCommand | ICommand | The old value. | 
| newCommand | ICommand | The new value. | 
OnCreateAutomationPeer()
Creates and returns an AutomationPeer object for this type.
protected override AutomationPeer OnCreateAutomationPeer()Returns
- AutomationPeer:
- The AutomationPeer that was created. 
OnIndeterminate()
Raises the IndeterminateEvent.
protected virtual void OnIndeterminate()OnKeyDown(KeyEventArgs)
Invoked when an unhandled Keyboard.KeyDownEvent attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
protected override void OnKeyDown(KeyEventArgs e)| Parameter | Type | Description | 
|---|---|---|
| e | KeyEventArgs | A KeyEventArgs that contains the event data. | 
OnKeyUp(KeyEventArgs)
Invoked when an unhandled Keyboard.KeyUpEvent attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
protected override void OnKeyUp(KeyEventArgs e)| Parameter | Type | Description | 
|---|---|---|
| e | KeyEventArgs | A KeyEventArgs that contains the event data. | 
OnLostKeyboardFocus(KeyboardFocusChangedEventArgs)
Called when an element loses keyboard focus.
protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e)| Parameter | Type | Description | 
|---|---|---|
| e | KeyboardFocusChangedEventArgs | The event data for the LostKeyboardFocus event. | 
OnLostMouseCapture(MouseEventArgs)
Called when an element no longer is receiving mouse event messages.
protected override void OnLostMouseCapture(MouseEventArgs e)| Parameter | Type | Description | 
|---|---|---|
| e | MouseEventArgs | The event data for the  | 
OnMouseEnter(MouseEventArgs)
Occurs when the mouse enters the control.
protected override void OnMouseEnter(MouseEventArgs e)| Parameter | Type | Description | 
|---|---|---|
| e | MouseEventArgs | A MouseEventArgs that contains the event data. | 
OnMouseLeave(MouseEventArgs)
Occurs when the mouse leaves the control.
protected override void OnMouseLeave(MouseEventArgs e)| Parameter | Type | Description | 
|---|---|---|
| e | MouseEventArgs | A MouseEventArgs that contains the event data. | 
OnMouseLeftButtonDown(MouseButtonEventArgs)
Invoked when an unhandled MouseLeftButtonDown routed event is raised on this element. Implement this method to add class handling for this event.
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)| Parameter | Type | Description | 
|---|---|---|
| e | MouseButtonEventArgs | The event data for the MouseLeftButtonDown event. | 
OnMouseLeftButtonUp(MouseButtonEventArgs)
Invoked when an unhandled MouseLeftButtonUp routed event is raised on this element. Implement this method to add class handling for this event.
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)| Parameter | Type | Description | 
|---|---|---|
| e | MouseButtonEventArgs | The event data for the MouseLeftButtonUp event. | 
OnMouseMove(MouseEventArgs)
Invoked when an unhandled Mouse.MouseMoveEvent attached event is raised on this element. Implement this method to add class handling for this event.
protected override void OnMouseMove(MouseEventArgs e)| Parameter | Type | Description | 
|---|---|---|
| e | MouseEventArgs | A MouseEventArgs that contains the event data. | 
OnPreviewClick(ExecuteRoutedEventArgs)
Raises the PreviewClick event.
protected override void OnPreviewClick(ExecuteRoutedEventArgs e)| Parameter | Type | Description | 
|---|---|---|
| e | ExecuteRoutedEventArgs | An  | 
OnPropertyChanged(DependencyPropertyChangedEventArgs)
Invoked whenever the effective value of any dependency property on this FrameworkElement has been updated. The specific dependency property that changed is reported in the arguments parameter.
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)| Parameter | Type | Description | 
|---|---|---|
| e | DependencyPropertyChangedEventArgs | The event data that describes the property that changed, as well as old and new values. | 
OnRenderSizeChanged(SizeChangedInfo)
Called when the rendered size of a control changes.
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)| Parameter | Type | Description | 
|---|---|---|
| sizeInfo | SizeChangedInfo | Specifies the size changes. | 
OnScreenTipOpening(RoutedEventArgs)
Invoked when an unhandled ScreenTipOpening attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
protected override void OnScreenTipOpening(RoutedEventArgs e)| Parameter | Type | Description | 
|---|---|---|
| e | RoutedEventArgs | A  | 
OnTouchLeave(TouchEventArgs)
Occurs when the touch device leaves the control.
protected override void OnTouchLeave(TouchEventArgs e)| Parameter | Type | Description | 
|---|---|---|
| e | TouchEventArgs | A TouchEventArgs that contains the event data. | 
OnUnchecked()
Raises the UncheckedEvent.
protected virtual void OnUnchecked()UpdateCanExecute()
Updates whether the command can execute.
protected override void UpdateCanExecute()Events
Checked
Occurs when the control is checked.
Indeterminate
Occurs when the checked state of the control is indeterminate.
Unchecked
Occurs when the control is unchecked.
Fields
CheckedEvent
Identifies the Checked routed event. This field is read-only.
public static readonly RoutedEvent CheckedEventClickModeProperty
Identifies the ClickMode dependency property. This field is read-only.
public static readonly DependencyProperty ClickModePropertyHasPopupProperty
Identifies the HasPopup dependency property. This field is read-only.
public static readonly DependencyProperty HasPopupPropertyImageSourceSmallSizeProperty
Identifies the ImageSourceSmallSize dependency property. This field is read-only.
public static readonly DependencyProperty ImageSourceSmallSizePropertyIndeterminateEvent
Identifies the Indeterminate routed event. This field is read-only.
public static readonly RoutedEvent IndeterminateEventInputGestureTextProperty
Identifies the InputGestureText dependency property. This field is read-only.
public static readonly DependencyProperty InputGestureTextPropertyIsCheckedProperty
Identifies the IsChecked dependency property. This field is read-only.
public static readonly DependencyProperty IsCheckedPropertyIsPointerOverProperty
Identifies the IsPointerOver dependency property. This field is read-only.
public static readonly DependencyProperty IsPointerOverPropertyIsPressedProperty
Identifies the IsPressed dependency property. This field is read-only.
public static readonly DependencyProperty IsPressedPropertyMenuItemDescriptionProperty
Identifies the MenuItemDescription dependency property.  This field is read-only.
public static readonly DependencyProperty MenuItemDescriptionPropertyStaysOpenOnClickProperty
Identifies the StaysOpenOnClick dependency property.  This field is read-only.
public static readonly DependencyProperty StaysOpenOnClickPropertyUncheckedEvent
Identifies the Unchecked routed event. This field is read-only.
public static readonly RoutedEvent UncheckedEventInherited Members
- ControlBase.ClickEvent
- ControlBase.PreviewClickEvent
- ControlBase.ScreenTipClosingEvent
- ControlBase.ScreenTipOpeningEvent
- ControlBase.CommandProperty
- ControlBase.CommandParameterProperty
- ControlBase.CommandTargetProperty
- ControlBase.ContextProperty
- ControlBase.HasImageProperty
- ControlBase.HasLabelProperty
- ControlBase.IdProperty
- ControlBase.ImageSourceLargeProperty
- ControlBase.ImageSourceSmallProperty
- ControlBase.IsHighlightedProperty
- ControlBase.KeyTipAccessTextProperty
- ControlBase.LabelProperty
- ControlBase.ScreenTipDescriptionProperty
- ControlBase.ScreenTipFooterProperty
- ControlBase.ScreenTipHeaderProperty
- ControlBase.ScreenTipHelpUriProperty
- ControlBase.ScreenTipImageSourceProperty
- ControlBase.VariantSizeProperty
- ControlBase.CoerceCommandParameter(DependencyObject, object)
- ControlBase.OnAccessKey(AccessKeyEventArgs)
- ControlBase.OnContextChanged(ControlContext, ControlContext)
- ControlBase.OnKeyTipAccessed(string)
- ControlBase.OnScreenTipClosing(RoutedEventArgs)
- ControlBase.OnVariantSizeChanged(VariantSize, VariantSize)
- ControlBase.RaiseClickEvent(ExecuteRoutedEventArgs)
- ControlBase.ToString()
- ControlBase.CanUpdateCanExecuteWhenHidden
- ControlBase.Command
- ControlBase.CommandParameter
- ControlBase.CommandTarget
- ControlBase.Context
- ControlBase.HasImage
- ControlBase.HasLabel
- ControlBase.Id
- ControlBase.ImageSourceLarge
- ControlBase.ImageSourceSmall
- ControlBase.IsHighlighted
- ControlBase.KeyTipAccessText
- ControlBase.Label
- ControlBase.ScreenTipDescription
- ControlBase.ScreenTipFooter
- ControlBase.ScreenTipHeader
- ControlBase.ScreenTipHelpUri
- ControlBase.ScreenTipImageSource
- ControlBase.VariantSize
- ControlBase.Click
- ControlBase.PreviewClick
- ControlBase.ScreenTipClosing
- ControlBase.ScreenTipOpening