ToggleSwitch styles and templates
Collapse the table of content
Expand the table of content

ToggleSwitch styles and templates

[ This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation ]

This topic describes the styles and templates for the ToggleSwitch control. You can modify these resources and the default ControlTemplate to give the control a unique appearance.

Visual states

These are the VisualStates defined in the control's default style.

VisualState nameVisualStateGroup nameDescription
NormalCommonStatesThe default state.
PointerOverCommonStatesThe pointer is positioned over the control.
PressedCommonStatesThe control is pressed.
DisabledCommonStatesThe control is disabled.
DraggingToggleStatesThe switch is being dragged.
OnToggleStatesThe switch is in the on position.
OffToggleStatesThe switch is in the off position.
OffContentContentStatesThe off content is shown.
OnContentContentStatesThe on content is shown.
FocusedFocusStatesThe control has focus.
UnfocusedFocusStatesThe control doesn't have focus.
PointerFocusedFocusStatesThe control has focus obtained through a pointer action.

 

For more info about focus states, see Control.FocusState.

Theme resources

These resources are used in the control's default style.

Dark theme brushes

To change the colors of the control in the dark theme, override these brushes in App.xaml.


<SolidColorBrush x:Key="ToggleSwitchCurtainBackgroundThemeBrush" Color="#FF5729C1" />
<SolidColorBrush x:Key="ToggleSwitchCurtainDisabledBackgroundThemeBrush" Color="Transparent" />
<SolidColorBrush x:Key="ToggleSwitchCurtainPointerOverBackgroundThemeBrush" Color="#FF6E46CA" />
<SolidColorBrush x:Key="ToggleSwitchCurtainPressedBackgroundThemeBrush" Color="#FF7E4FEC" />

<SolidColorBrush x:Key="ToggleSwitchDisabledForegroundThemeBrush" Color="#66FFFFFF" />
<SolidColorBrush x:Key="ToggleSwitchForegroundThemeBrush" Color="#FFFFFFFF" />

<SolidColorBrush x:Key="ToggleSwitchHeaderDisabledForegroundThemeBrush" Color="#66FFFFFF" />            
<SolidColorBrush x:Key="ToggleSwitchHeaderForegroundThemeBrush" Color="#FFFFFFFF" />            

<SolidColorBrush x:Key="ToggleSwitchOuterBorderBorderThemeBrush" Color="#59FFFFFF" />            
<SolidColorBrush x:Key="ToggleSwitchOuterBorderDisabledBorderThemeBrush" Color="#33FFFFFF" />            

<SolidColorBrush x:Key="ToggleSwitchThumbBackgroundThemeBrush" Color="#FFFFFFFF" />            
<SolidColorBrush x:Key="ToggleSwitchThumbBorderThemeBrush" Color="#FFFFFFFF" />            
<SolidColorBrush x:Key="ToggleSwitchThumbDisabledBackgroundThemeBrush" Color="#FF7E7E7E" />            
<SolidColorBrush x:Key="ToggleSwitchThumbDisabledBorderThemeBrush" Color="#FF7E7E7E" />            
<SolidColorBrush x:Key="ToggleSwitchThumbPointerOverBackgroundThemeBrush" Color="#FFFFFFFF" />            
<SolidColorBrush x:Key="ToggleSwitchThumbPointerOverBorderThemeBrush" Color="#FFFFFFFF" />
<SolidColorBrush x:Key="ToggleSwitchThumbPressedBackgroundThemeBrush" Color="#FFFFFFFF" />
<SolidColorBrush x:Key="ToggleSwitchThumbPressedForegroundThemeBrush" Color="#FFFFFFFF" />

<SolidColorBrush x:Key="ToggleSwitchTrackBackgroundThemeBrush" Color="#42FFFFFF" />
<SolidColorBrush x:Key="ToggleSwitchTrackBorderThemeBrush" Color="Transparent" />
<SolidColorBrush x:Key="ToggleSwitchTrackDisabledBackgroundThemeBrush" Color="#1FFFFFFF" />
<SolidColorBrush x:Key="ToggleSwitchTrackPointerOverBackgroundThemeBrush" Color="#4AFFFFFF" />
<SolidColorBrush x:Key="ToggleSwitchTrackPressedBackgroundThemeBrush" Color="#59FFFFFF" />

Light theme brushes

To change the colors of the control in the light theme, override these brushes in App.xaml.


<SolidColorBrush x:Key="ToggleSwitchCurtainBackgroundThemeBrush" Color="#FF4617B4" />
<SolidColorBrush x:Key="ToggleSwitchCurtainDisabledBackgroundThemeBrush" Color="Transparent" />
<SolidColorBrush x:Key="ToggleSwitchCurtainPointerOverBackgroundThemeBrush" Color="#FF5F37BE" />
<SolidColorBrush x:Key="ToggleSwitchCurtainPressedBackgroundThemeBrush" Color="#FF7241E4" />

<SolidColorBrush x:Key="ToggleSwitchDisabledForegroundThemeBrush" Color="#66000000" />
<SolidColorBrush x:Key="ToggleSwitchForegroundThemeBrush" Color="#FF000000" />

<SolidColorBrush x:Key="ToggleSwitchHeaderDisabledForegroundThemeBrush" Color="#66000000" />
<SolidColorBrush x:Key="ToggleSwitchHeaderForegroundThemeBrush" Color="#FF000000" />

<SolidColorBrush x:Key="ToggleSwitchOuterBorderBorderThemeBrush" Color="#59000000" />
<SolidColorBrush x:Key="ToggleSwitchOuterBorderDisabledBorderThemeBrush" Color="#33000000" />

<SolidColorBrush x:Key="ToggleSwitchThumbBackgroundThemeBrush" Color="#FF000000" />
<SolidColorBrush x:Key="ToggleSwitchThumbBorderThemeBrush" Color="#FF000000" />
<SolidColorBrush x:Key="ToggleSwitchThumbDisabledBackgroundThemeBrush" Color="#FF929292" />
<SolidColorBrush x:Key="ToggleSwitchThumbDisabledBorderThemeBrush" Color="#FF929292" />
<SolidColorBrush x:Key="ToggleSwitchThumbPointerOverBackgroundThemeBrush" Color="#FF000000" />
<SolidColorBrush x:Key="ToggleSwitchThumbPointerOverBorderThemeBrush" Color="#FF000000" />
<SolidColorBrush x:Key="ToggleSwitchThumbPressedBackgroundThemeBrush" Color="#FF000000" />
<SolidColorBrush x:Key="ToggleSwitchThumbPressedForegroundThemeBrush" Color="#FF000000" />

<SolidColorBrush x:Key="ToggleSwitchTrackBackgroundThemeBrush" Color="#59000000" />
<SolidColorBrush x:Key="ToggleSwitchTrackBorderThemeBrush" Color="Transparent" />
<SolidColorBrush x:Key="ToggleSwitchTrackDisabledBackgroundThemeBrush" Color="#1F000000" />
<SolidColorBrush x:Key="ToggleSwitchTrackPointerOverBackgroundThemeBrush" Color="#4A000000" />
<SolidColorBrush x:Key="ToggleSwitchTrackPressedBackgroundThemeBrush" Color="#42000000" />

Other resources

The default style doesn't use any additional control specific resources.

For more info on theme resources, including the values that are used for the HighContrast theme, see XAML theme resources reference.

Shared resources

The control template uses these resources that are shared with other control templates. Changing these values will affect other controls that use these resources.



<FontFamily x:Key="ContentControlThemeFontFamily">Segoe UI</FontFamily>
<x:Double x:Key="ControlContentThemeFontSize">14.667</x:Double>
<SolidColorBrush x:Key="FocusVisualBlackStrokeThemeBrush" Color="Black" />
<SolidColorBrush x:Key="FocusVisualWhiteStrokeThemeBrush" Color="White" />

Default style


<!-- Default style for Windows.UI.Xaml.Controls.ToggleSwitch -->
<Style TargetType="ToggleSwitch">
    <Setter Property="Foreground" Value="{ThemeResource ToggleSwitchForegroundThemeBrush}" />
    <Setter Property="HorizontalAlignment" Value="Left" />
    <Setter Property="VerticalAlignment" Value="Center" />
    <Setter Property="HorizontalContentAlignment" Value="Left" />
    <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
    <Setter Property="FontWeight" Value="SemiBold" />
    <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
    <Setter Property="MinWidth" Value="154" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ToggleSwitch">
                <Border Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}">
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="Normal" />
                            <VisualState x:Name="PointerOver">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SwitchCurtain"
                                                                   Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchCurtainPointerOverBackgroundThemeBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="InnerBorder"
                                                                   Storyboard.TargetProperty="Background">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchTrackPointerOverBackgroundThemeBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SwitchKnob"
                                                                   Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchThumbPointerOverBackgroundThemeBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SwitchKnob"
                                                                   Storyboard.TargetProperty="Stroke">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchThumbPointerOverBorderThemeBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Pressed">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SwitchCurtain"
                                                                   Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchCurtainPressedBackgroundThemeBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="InnerBorder"
                                                                   Storyboard.TargetProperty="Background">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchTrackPressedBackgroundThemeBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SwitchKnob"
                                                                   Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchThumbPressedBackgroundThemeBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SwitchKnob"
                                                                   Storyboard.TargetProperty="Stroke">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchThumbPressedForegroundThemeBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Disabled">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderContentPresenter"
                                                                   Storyboard.TargetProperty="Foreground">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchHeaderDisabledForegroundThemeBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="OffContentPresenter"
                                                                   Storyboard.TargetProperty="Foreground">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchDisabledForegroundThemeBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="OnContentPresenter"
                                                                   Storyboard.TargetProperty="Foreground">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchDisabledForegroundThemeBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="OuterBorder"
                                                                   Storyboard.TargetProperty="BorderBrush">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchOuterBorderDisabledBorderThemeBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="InnerBorder"
                                                                   Storyboard.TargetProperty="Background">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchTrackDisabledBackgroundThemeBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SwitchKnob"
                                                                   Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchThumbDisabledBackgroundThemeBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SwitchKnob"
                                                                   Storyboard.TargetProperty="Stroke">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchThumbDisabledBorderThemeBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SwitchCurtain"
                                                                   Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchCurtainDisabledBackgroundThemeBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="ToggleStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition x:Name="DraggingToOnTransition"
                                                  From="Dragging"
                                                  To="On"
                                                  GeneratedDuration="0">
                                    <Storyboard>
                                        <RepositionThemeAnimation TargetName="SwitchKnob" FromHorizontalOffset="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.KnobCurrentToOnOffset}" />
                                        <RepositionThemeAnimation TargetName="SwitchCurtain" FromHorizontalOffset="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.CurtainCurrentToOnOffset}" />
                                    </Storyboard>
                                </VisualTransition>
                                <VisualTransition x:Name="DraggingToOffTransition"
                                                  From="Dragging"
                                                  To="Off"
                                                  GeneratedDuration="0">
                                    <Storyboard>
                                        <RepositionThemeAnimation TargetName="SwitchKnob" FromHorizontalOffset="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.KnobCurrentToOffOffset}" />
                                        <RepositionThemeAnimation TargetName="SwitchCurtain" FromHorizontalOffset="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.CurtainCurrentToOffOffset}" />
                                    </Storyboard>
                                </VisualTransition>
                                <VisualTransition x:Name="OnToOffTransition"
                                                  From="On"
                                                  To="Off"
                                                  GeneratedDuration="0">
                                    <Storyboard>
                                        <RepositionThemeAnimation TargetName="SwitchKnob" FromHorizontalOffset="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.KnobOnToOffOffset}" />
                                        <RepositionThemeAnimation TargetName="SwitchCurtain" FromHorizontalOffset="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.CurtainOnToOffOffset}" />
                                    </Storyboard>
                                </VisualTransition>
                                <VisualTransition x:Name="OffToOnTransition"
                                                  From="Off"
                                                  To="On"
                                                  GeneratedDuration="0">
                                    <Storyboard>
                                        <RepositionThemeAnimation TargetName="SwitchKnob" FromHorizontalOffset="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.KnobOffToOnOffset}" />
                                        <RepositionThemeAnimation TargetName="SwitchCurtain" FromHorizontalOffset="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.CurtainOffToOnOffset}" />
                                    </Storyboard>
                                </VisualTransition>
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="Dragging" />
                            <VisualState x:Name="Off">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="CurtainTranslateTransform"
                                                     Storyboard.TargetProperty="X"
                                                     To="-44"
                                                     Duration="0" />
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="On">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="CurtainTranslateTransform"
                                                     Storyboard.TargetProperty="X"
                                                     To="0"
                                                     Duration="0" />
                                    <DoubleAnimation Storyboard.TargetName="KnobTranslateTransform"
                                                     Storyboard.TargetProperty="X"
                                                     To="38"
                                                     Duration="0" />
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="ContentStates">
                            <VisualState x:Name="OffContent">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="OffContentPresenter"
                                                     Storyboard.TargetProperty="Opacity"
                                                     To="1"
                                                     Duration="0" />
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsHitTestVisible" Storyboard.TargetName="OffContentPresenter">
                                        <DiscreteObjectKeyFrame KeyTime="0">
                                            <DiscreteObjectKeyFrame.Value>
                                                <x:Boolean>True</x:Boolean>
                                            </DiscreteObjectKeyFrame.Value>
                                        </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="OnContent">
                                <Storyboard>
                                   <DoubleAnimation Storyboard.TargetName="OnContentPresenter"
                                                     Storyboard.TargetProperty="Opacity"
                                                     To="1"
                                                     Duration="0" />
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsHitTestVisible" Storyboard.TargetName="OnContentPresenter">
                                        <DiscreteObjectKeyFrame KeyTime="0">
                                            <DiscreteObjectKeyFrame.Value>
                                                <x:Boolean>True</x:Boolean>
                                            </DiscreteObjectKeyFrame.Value>
                                        </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="FocusStates">
                            <VisualState x:Name="Focused">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="FocusVisualWhite"
                                                     Storyboard.TargetProperty="Opacity"
                                                     To="1"
                                                     Duration="0" />
                                    <DoubleAnimation Storyboard.TargetName="FocusVisualBlack"
                                                     Storyboard.TargetProperty="Opacity"
                                                     To="1"
                                                     Duration="0" />
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Unfocused" />
                            <VisualState x:Name="PointerFocused" />
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <ContentPresenter x:Name="HeaderContentPresenter"
                                          Foreground="{ThemeResource ToggleSwitchHeaderForegroundThemeBrush}"
                                          Margin="6"
                                          Grid.ColumnSpan="2"
                                          Content="{TemplateBinding Header}"
                                          ContentTemplate="{TemplateBinding HeaderTemplate}"
                                          FontWeight="Semilight"
                                          AutomationProperties.AccessibilityView="Raw" />
                        <Grid Grid.Row="1" Margin="{TemplateBinding Padding}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="7" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <ContentPresenter x:Name="OffContentPresenter"
                                              MinWidth="65"
                                              Margin="6,5,0,16"
                                              Opacity="0"
                                              IsHitTestVisible="False"
                                              Content="{TemplateBinding OffContent}"
                                              ContentTemplate="{TemplateBinding OffContentTemplate}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              AutomationProperties.AccessibilityView="Raw" />
                            <ContentPresenter x:Name="OnContentPresenter"
                                              MinWidth="65"
                                              Margin="6,5,0,16"
                                              Opacity="0"
                                              IsHitTestVisible="False"
                                              Content="{TemplateBinding OnContent}"
                                              ContentTemplate="{TemplateBinding OnContentTemplate}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              AutomationProperties.AccessibilityView="Raw" />
                            <Grid Grid.Column="2" Background="Transparent" ManipulationMode="None">
                                <Grid x:Name="SwitchKnobBounds" Height="19" Margin="13,5,13,16">
                                    <Border x:Name="OuterBorder"
                                            BorderBrush="{ThemeResource ToggleSwitchOuterBorderBorderThemeBrush}"
                                            BorderThickness="2">
                                        <Border x:Name="InnerBorder"
                                                Background="{ThemeResource ToggleSwitchTrackBackgroundThemeBrush}"
                                                BorderBrush="{ThemeResource ToggleSwitchTrackBorderThemeBrush}"
                                                BorderThickness="1">
                                            <ContentPresenter x:Name="SwitchCurtainBounds">
                                                <ContentPresenter x:Name="SwitchCurtainClip">
                                                    <Rectangle x:Name="SwitchCurtain"
                                                               Fill="{ThemeResource ToggleSwitchCurtainBackgroundThemeBrush}"
                                                               Width="44">
                                                        <Rectangle.RenderTransform>
                                                            <TranslateTransform x:Name="CurtainTranslateTransform" X="-44" />
                                                        </Rectangle.RenderTransform>
                                                    </Rectangle>
                                                </ContentPresenter>
                                            </ContentPresenter>
                                        </Border>
                                    </Border>
                                    <Rectangle x:Name="SwitchKnob"
                                               Fill="{ThemeResource ToggleSwitchThumbBackgroundThemeBrush}"
                                               Stroke="{ThemeResource ToggleSwitchThumbBorderThemeBrush}"
                                               StrokeThickness="1"
                                               HorizontalAlignment="Left"
                                               Width="12">
                                        <Rectangle.RenderTransform>
                                            <TranslateTransform x:Name="KnobTranslateTransform" />
                                        </Rectangle.RenderTransform>
                                    </Rectangle>
                                    <Rectangle x:Name="FocusVisualWhite"
                                               Stroke="{ThemeResource FocusVisualWhiteStrokeThemeBrush}"
                                               StrokeEndLineCap="Square"
                                               StrokeDashArray="1,1"
                                               Opacity="0"
                                               Margin="-3"
                                               StrokeDashOffset="1.5" />
                                    <Rectangle x:Name="FocusVisualBlack"
                                               Stroke="{ThemeResource FocusVisualBlackStrokeThemeBrush}"
                                               StrokeEndLineCap="Square"
                                               StrokeDashArray="1,1"
                                               Opacity="0"
                                               Margin="-3"
                                               StrokeDashOffset="0.5" />
                                </Grid>
                                <Thumb x:Name="SwitchThumb" AutomationProperties.AccessibilityView="Raw">
                                    <Thumb.Template>
                                        <ControlTemplate TargetType="Thumb">
                                            <Rectangle Fill="Transparent" />
                                        </ControlTemplate>
                                    </Thumb.Template>
                                </Thumb>
                            </Grid>
                        </Grid>
                    </Grid>
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

 

 

Show:
© 2017 Microsoft