Summary
A control that allows the user to toggle between two states: One represents true; The other represents false.
- Namespace
- MahApps
.Metro .Controls - Interfaces
-
- ICommandSource
- Base Types
-
- Headered
Content Control
- Headered
graph BT
Type-->Base0["HeaderedContentControl"]
Type-.->Interface0["ICommandSource"]
Type["ToggleSwitch"]
class Type type-node
Syntax
[System.Diagnostics.CodeAnalysis.SuppressMessage("WpfAnalyzers.TemplatePart", "WPF0132:Use PART prefix.", Justification = "<Pending>")]
[ContentProperty(nameof(Content))]
[TemplatePart(Name = nameof(HeaderContentPresenter), Type = typeof(ContentPresenter))]
[TemplatePart(Name = nameof(ContentPresenter), Type = typeof(ContentPresenter))]
[TemplatePart(Name = nameof(OffContentPresenter), Type = typeof(ContentPresenter))]
[TemplatePart(Name = nameof(OnContentPresenter), Type = typeof(ContentPresenter))]
[TemplatePart(Name = nameof(SwitchKnobBounds), Type = typeof(FrameworkElement))]
[TemplatePart(Name = nameof(SwitchKnob), Type = typeof(FrameworkElement))]
[TemplatePart(Name = nameof(KnobTranslateTransform), Type = typeof(TranslateTransform))]
[TemplatePart(Name = nameof(SwitchThumb), Type = typeof(Thumb))]
[TemplateVisualState(GroupName = VisualStates.GroupCommon, Name = VisualStates.StateNormal)]
[TemplateVisualState(GroupName = VisualStates.GroupCommon, Name = VisualStates.StateMouseOver)]
[TemplateVisualState(GroupName = VisualStates.GroupCommon, Name = VisualStates.StatePressed)]
[TemplateVisualState(GroupName = VisualStates.GroupCommon, Name = VisualStates.StateDisabled)]
[TemplateVisualState(GroupName = ContentStatesGroup, Name = OffContentState)]
[TemplateVisualState(GroupName = ContentStatesGroup, Name = OnContentState)]
[TemplateVisualState(GroupName = ToggleStatesGroup, Name = DraggingState)]
[TemplateVisualState(GroupName = ToggleStatesGroup, Name = OffState)]
[TemplateVisualState(GroupName = ToggleStatesGroup, Name = OnState)]
public class ToggleSwitch : HeaderedContentControl, ICommandSource
Attributes
Type | Description |
---|---|
Suppress |
|
ContentProperty | |
TemplatePart | |
TemplatePart | |
TemplatePart | |
TemplatePart | |
TemplatePart | |
TemplatePart | |
TemplatePart | |
TemplatePart | |
TemplateVisualState | |
TemplateVisualState | |
TemplateVisualState | |
TemplateVisualState | |
TemplateVisualState | |
TemplateVisualState | |
TemplateVisualState | |
TemplateVisualState | |
TemplateVisualState |
Constructors
Name | Summary |
---|---|
ToggleSwitch |
Events
Name | Type | Summary |
---|---|---|
Toggled | RoutedEventHandler |
Occurs when "On"/"Off" state changes for this ToggleSwitch.
|
Fields
Name | Constant Value | Summary |
---|---|---|
Command |
Identifies the
CommandParameter dependency property.static
|
|
CommandProperty |
Identifies the
Command dependency property.static
|
|
Command |
Identifies the
CommandTarget dependency property.static
|
|
Content |
Identifies the
ContentDirection dependency property.static
|
|
Content |
Identifies the
ContentPadding dependency property.static
|
|
IsOnProperty |
Identifies the
IsOn dependency property.static
|
|
IsPressedProperty |
Identifies the
IsPressed dependency property.static
|
|
OffCommandProperty |
Identifies the
OffCommand dependency property.static
|
|
OffContentProperty |
Identifies the
OffContent dependency property.static
|
|
Off |
Identifies the
OffContentStringFormat dependency property.static
|
|
Off |
Identifies the
OffContentTemplate dependency property.static
|
|
Off |
Identifies the
OffContentTemplateSelector dependency property.static
|
|
OnCommandProperty |
Identifies the
OnCommand dependency property.static
|
|
OnContentProperty |
Identifies the
OnContent dependency property.static
|
|
On |
Identifies the
OnContentStringFormat dependency property.static
|
|
On |
Identifies the
OnContentTemplate dependency property.static
|
|
On |
Identifies the
OnContentTemplateSelector dependency property.static
|
Properties
Name | Value | Summary |
---|---|---|
Command | ICommand |
Gets or sets a command which will be executed when the
IsOnProperty changes.
|
CommandParameter | object |
Gets or sets the command parameter which will be passed by the Command.
|
CommandTarget | IInputElement |
Gets or sets the element on which to raise the specified Command.
|
ContentDirection | FlowDirection |
Gets or sets the flow direction of the switch and content.
|
ContentPadding | Thickness |
Gets or sets the padding of the inner content.
|
IsEnabledCore | bool | |
IsOn | bool |
Gets or sets a value that declares whether the state of the ToggleSwitch is "On".
|
IsPressed | bool | |
OffCommand | ICommand |
Gets or sets a command which will be executed when the
IsOnProperty changes.
|
OffContent | object |
Provides the object content that should be displayed using the OffContentTemplate when this ToggleSwitch has state of "Off".
|
Off |
string |
Gets or sets a composite string that specifies how to format the OffContent property if it is displayed as a string.
|
OffContentTemplate | DataTemplate |
Gets or sets the DataTemplate used to display the control's content while in "Off" state.
|
Off |
DataTemplateSelector |
Gets or sets a template selector for OffContent property that enables an application writer to provide custom template-selection logic .
|
OnCommand | ICommand |
Gets or sets a command which will be executed when the
IsOnProperty changes.
|
OnContent | object |
Provides the object content that should be displayed using the OnContentTemplate when this ToggleSwitch has state of "On".
|
On |
string |
Gets or sets a composite string that specifies how to format the OnContent property if it is displayed as a string.
|
OnContentTemplate | DataTemplate |
Gets or sets the DataTemplate used to display the control's content while in "On" state.
|
On |
DataTemplateSelector |
Gets or sets a template selector for OnContent property that enables an application writer to provide custom template-selection logic .
|
Methods
Name | Value | Summary |
---|---|---|
OnApplyTemplate |
void | |
OnContentChanged |
void | |
On |
AutomationPeer | |
OnHeaderChanged |
void | |
OnKeyUp |
void | |
OnOffContentChanged |
void | |
OnOnContentChanged |
void | |
OnPropertyChanged |
void | |
OnRenderSizeChanged |
void | |
OnToggled |
void |
This method is invoked when the
IsOnProperty changes. |