Thumb 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 Thumb 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 name VisualStateGroup name Description
Normal CommonStates The default state.
PointerOver CommonStates The pointer is positioned over the control.
Pressed CommonStates The control is pressed.
Disabled CommonStates The control is disabled.
Focused FocusStates The control has focus.
Unfocused FocusStates The control doesn't have focus.

 

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="ThumbBackgroundThemeBrush" Color="#FFCDCDCD" />
<SolidColorBrush x:Key="ThumbBorderThemeBrush" Color="#3B555555" />
<SolidColorBrush x:Key="ThumbPointerOverBackgroundThemeBrush" Color="#FFDADADA"/>
<SolidColorBrush x:Key="ThumbPointerOverBorderThemeBrush" Color="#6BB7B7B7"/>
<SolidColorBrush x:Key="ThumbPressedBackgroundThemeBrush" Color="#99000000" />
<SolidColorBrush x:Key="ThumbPressedBorderThemeBrush" Color="#ED555555"/>

Light theme brushes

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

<SolidColorBrush x:Key="ThumbBackgroundThemeBrush" Color="#FFCDCDCD"/>
<SolidColorBrush x:Key="ThumbBorderThemeBrush" Color="#3B555555"/>
<SolidColorBrush x:Key="ThumbPointerOverBackgroundThemeBrush" Color="#FFDADADA"/>
<SolidColorBrush x:Key="ThumbPointerOverBorderThemeBrush" Color="#6BB7B7B7"/>
<SolidColorBrush x:Key="ThumbPressedBackgroundThemeBrush" Color="#99000000"/>
<SolidColorBrush x:Key="ThumbPressedBorderThemeBrush" Color="#ED555555"/>

Other resources

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

Default style

<!-- Default style for Windows.UI.Xaml.Controls.Primitives.Thumb -->
<Style TargetType="Thumb">
    <Setter Property="Background" Value="{ThemeResource ThumbBackgroundThemeBrush}"/>
    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="IsTabStop" Value="False" />
    <Setter Property="BorderBrush" Value="{ThemeResource ThumbBorderThemeBrush}" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Thumb">
                <Grid>
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="Normal"/>
                            <VisualState x:Name="PointerOver">
                                <Storyboard>
                                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundPointerOver"/>
                                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Background" />
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Pressed">
                                <Storyboard>
                                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundPressed"/>
                                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Background" />
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Disabled"/>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="FocusStates">
                            <VisualState x:Name="Unfocused"/>
                            <VisualState x:Name="Focused"/>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <Border x:Name="Background" 
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"/>
                    <Border x:Name="BackgroundPointerOver"
                            Background="{ThemeResource ThumbPointerOverBackgroundThemeBrush}"
                            BorderBrush="{ThemeResource ThumbPointerOverBorderThemeBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Opacity="0"/>
                    <Border x:Name="BackgroundPressed"
                            Background="{ThemeResource ThumbPressedBackgroundThemeBrush}"
                            BorderBrush="{ThemeResource ThumbPressedBorderThemeBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Opacity="0"/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>