-
Notifications
You must be signed in to change notification settings - Fork 3
FlatButton
Back to home | Back to Reference | View raw text
A button with a custom, flat style and additional funcionality. Use SelectOnClick
to have the button act like a toggle button.
flowchart LR
classDef interfaceStyle stroke-dasharray: 5 5;
classDef abstractStyle stroke-width:4px
subgraph SolidShineUi
SolidShineUi.FlatButton[[FlatButton]]
end
subgraph System.Windows.Controls.Primitives
System.Windows.Controls.Primitives.ButtonBase[[ButtonBase]]
end
System.Windows.Controls.Primitives.ButtonBase --> SolidShineUi.FlatButton
Type | Name | Methods |
---|---|---|
Brush |
Background Get or set the brush used for the background of the control. |
get, set |
Brush |
BorderBrush Get or set the brush used for the border around the edges of the control. |
get, set |
Brush |
BorderDisabledBrush Get or set the brush used for the border of the control when the control is disabled. |
get, set |
Brush |
BorderHighlightBrush Get or set the brush used for the border while the control has the mouse over it (or it has keyboard focus). |
get, set |
Brush |
BorderSelectedBrush Get or set the brush used for the border while the control is selected (i.e. the IsSelected property is true). |
get, set |
Thickness |
BorderSelectionThickness Get or set the thickness of the border around the button, while the button is in a selected ( IsSelected ) state. |
get, set |
Thickness |
BorderThickness Get or set the thickness of the border around the button. |
get, set |
Brush |
ClickBrush Get or set the brush used for the background of the control while the mouse is clicking it. |
get, set |
ColorScheme |
ColorScheme Get or set the color scheme to apply to this button. The color scheme can quickly apply a whole visual style to your control. |
get, set |
CornerRadius |
CornerRadius Get or set the corner radius (or radii) to use for the button and its border. Can be used to create a rounded button. |
get, set |
Brush |
DisabledBrush Get or set the brush used for the background of the control when the control is disabled. |
get, set |
Brush |
HighlightBrush Get or set the brush used for the background of the control while the mouse is over it, or it has keyboard focus. |
get, set |
bool |
IsDefault Get or set if this button is the default button in the dialog or window it is located in. May not currently function correctly. |
get, set |
bool |
IsDefaulted Specifies whether or not this button is the button that would be invoked when Enter is pressed. |
get |
bool |
IsSelected Gets or sets whether this button is selected. This property (combined with SelectOnClick ) allows the button to function like a ToggleButton. |
get, set |
bool |
SelectOnClick Gets or sets whether the button should change its IsSelected property when a click is performed. With this enabled, this allows the button to take on the functionality of a ToggleButton. |
get, set |
Brush |
SelectedBrush Get or set the brush used for the background of this button while it is selected (i.e. the IsSelected property is true). |
get, set |
bool |
TransparentBack Get or set whether the button should have a transparent background when the button is not focused. |
get, set |
bool |
UseAccentColors Get or set if the button should use the accent colors of the color scheme, rather than the standard colors. |
get, set |
Returns | Name |
---|---|
bool |
GetIsMouseDown (DependencyObject obj)Get the IsMouseDown property for a FlatButton. |
void |
OnColorSchemeChanged (DependencyObject d, DependencyPropertyChangedEventArgs e)Perform an action when the ColorScheme property has changed. Primarily used internally. |
void |
OnIsSelectedChanged (DependencyObject d, DependencyPropertyChangedEventArgs e)Perform an action when a property of an object has changed. Primarily used internally. |
void |
OnTransparentBackChanged (DependencyObject d, DependencyPropertyChangedEventArgs e)Perform an action when a property of an object has changed. Primarily used internally. |
void |
OnUseAccentColorsChanged (DependencyObject d, DependencyPropertyChangedEventArgs e)Perform an action when a property of an object has changed. Primarily used internally. |
Returns | Name |
---|---|
void |
SetIsMouseDown (DependencyObject obj, bool value)Set the IsMouseDown property for a FlatButton. |
Returns | Name |
---|---|
void |
ApplyColorScheme (... )Apply a color scheme to this control, and set some other optional appearance settings. The color scheme can quickly apply a whole visual style to the control. |
void |
DoClick ()Perform a click programattically. The button responds the same way as if it was clicked by the user. |
Returns | Name |
---|---|
void |
OnClick ()Defines the actions the button performs when it is clicked. |
A button with a custom, flat style and additional funcionality. Use SelectOnClick
to have the button act like a toggle button.
ButtonBase
public FlatButton()
Create a new FlatButton.
public static void OnColorSchemeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
Type | Name | Description |
---|---|---|
DependencyObject |
d | The object containing the property that changed. |
DependencyPropertyChangedEventArgs |
e | Event arguments about the property change. |
Perform an action when the ColorScheme property has changed. Primarily used internally.
public static void OnTransparentBackChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
Type | Name | Description |
---|---|---|
DependencyObject |
d | The object containing the property that changed. |
DependencyPropertyChangedEventArgs |
e | Event arguments about the property change. |
Perform an action when a property of an object has changed. Primarily used internally.
public static void OnUseAccentColorsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
Type | Name | Description |
---|---|---|
DependencyObject |
d | The object containing the property that changed. |
DependencyPropertyChangedEventArgs |
e | Event arguments about the property change. |
Perform an action when a property of an object has changed. Primarily used internally.
public void ApplyColorScheme(ColorScheme cs, bool transparentBack, bool useAccentColors)
Type | Name | Description |
---|---|---|
ColorScheme |
cs | The color scheme to apply |
bool |
transparentBack | Set if the button should have no background when not focused or highlighted. This can also be achieved with the TransparentBack property. |
bool |
useAccentColors | Set if accent colors should be used for this button, rather than the main color scheme colors. This can also be achieved with the UseAccentColors property. |
Apply a color scheme to this control, and set some other optional appearance settings. The color scheme can quickly apply a whole visual style to the control.
public void ApplyColorScheme(HighContrastOption hco, bool transparentBack)
Type | Name | Description |
---|---|---|
HighContrastOption |
hco | The high-contrast color scheme to apply. |
bool |
transparentBack | Set if the button should have no background when not focused or highlighted. This can also be achieved with the TransparentBack property. |
Apply a color scheme to this control. The color scheme can quickly apply a whole visual style to the control.
protected static void SetIsMouseDown(DependencyObject obj, bool value)
Type | Name | Description |
---|---|---|
DependencyObject |
obj | The FlatButton to apply the property change to. |
bool |
value | The new value to set for the property. |
Set the IsMouseDown property for a FlatButton.
public static bool GetIsMouseDown(DependencyObject obj)
Type | Name | Description |
---|---|---|
DependencyObject |
obj | The Flatbutton to get the property value from. |
Get the IsMouseDown property for a FlatButton.
public static void OnIsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
Type | Name | Description |
---|---|---|
DependencyObject |
d | The object containing the property that changed. |
DependencyPropertyChangedEventArgs |
e | Event arguments about the property change. |
Perform an action when a property of an object has changed. Primarily used internally.
public void DoClick()
Perform a click programattically. The button responds the same way as if it was clicked by the user.
protected override void OnClick()
Defines the actions the button performs when it is clicked.
public Brush Background { get; set; }
Get or set the brush used for the background of the control.
public Brush ClickBrush { get; set; }
Get or set the brush used for the background of the control while the mouse is clicking it.
public Brush SelectedBrush { get; set; }
Get or set the brush used for the background of this button while it is selected
(i.e. the IsSelected
property is true).
public Brush HighlightBrush { get; set; }
Get or set the brush used for the background of the control while the mouse is over it, or it has keyboard focus.
public Brush DisabledBrush { get; set; }
Get or set the brush used for the background of the control when the control is disabled.
public Brush BorderDisabledBrush { get; set; }
Get or set the brush used for the border of the control when the control is disabled.
public Brush BorderBrush { get; set; }
Get or set the brush used for the border around the edges of the control.
public Brush BorderHighlightBrush { get; set; }
Get or set the brush used for the border while the control has the mouse over it (or it has keyboard focus).
public Brush BorderSelectedBrush { get; set; }
Get or set the brush used for the border while the control is selected
(i.e. the IsSelected
property is true).
public ColorScheme ColorScheme { get; set; }
Get or set the color scheme to apply to this button. The color scheme can quickly apply a whole visual style to your control.
public bool TransparentBack { get; set; }
Get or set whether the button should have a transparent background when the button is not focused.
public bool UseAccentColors { get; set; }
Get or set if the button should use the accent colors of the color scheme, rather than the standard colors.
public Thickness BorderThickness { get; set; }
Get or set the thickness of the border around the button.
public Thickness BorderSelectionThickness { get; set; }
Get or set the thickness of the border around the button, while the button is in a selected ( IsSelected
) state.
public CornerRadius CornerRadius { get; set; }
Get or set the corner radius (or radii) to use for the button and its border. Can be used to create a rounded button.
public bool IsSelected { get; set; }
Gets or sets whether this button is selected. This property (combined with SelectOnClick
) allows the button to function like a ToggleButton.
A selected button will have a slightly different visual appearance to differentiate it as being selected. This will include, by default, the border being a bit thicker. This can be changed via the FlatButton.BorderSelectionThickness property. You can also directly edit the brushes used via the FlatButton.SelectedBrush and FlatButton.BorderSelectedBrush properties.
public bool SelectOnClick { get; set; }
Gets or sets whether the button should change its IsSelected property when a click is performed. With this enabled, this allows the button to take on the functionality of a ToggleButton.
While SelectOnClick is true, the button will toggle between FlatButton.IsSelected being true and false (similar to a ToggleButton). A selected button will, by default, have some visual
differences to help make it look distinct from unselected buttons. The button's Click event will still be raised while this property is set to true
, but the event occurs after the
IsSelected property has already changed. While you could use the Click event to check when the button's IsSelected property is changed, it is better to use the IsSelectedChanged event,
in case of situations where IsSelected is changed via methods other than clicking, such as programmatically or via WPF binding.
public bool IsDefault { get; set; }
Get or set if this button is the default button in the dialog or window it is located in. May not currently function correctly.
public bool IsDefaulted { get; }
Specifies whether or not this button is the button that would be invoked when Enter is pressed.
public event DependencyPropertyChangedEventHandler IsSelectedChanged
Raised if the button's IsSelected value is changed. This can be used to have the button act as a ToggleButton.
public event DependencyPropertyChangedEventHandler ColorSchemeChanged
Raised when the ColorScheme property is changed.
public event RoutedEventHandler RightClick
Raised when the user right-clicks on the button, via a mouse click or via the keyboard.
Generated with ModularDoc