UWP 滚动条私人定制

Posted lonelyxmas

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UWP 滚动条私人定制相关的知识,希望对你有一定的参考价值。

原文:UWP 滚动条私人定制

最近突然发现微软自带的滚动条好挫哦

 

微软哒(棒棒哒)

 技术分享图片

 

 

网上找的(美美哒)

技术分享图片

 

 

好了。

如果你想要棒棒哒,那么就不用往下看了(手动再见)。

如果你想要美美哒,就需要下面的神秘代码。

 

技术分享图片

 

    <Style TargetType="ScrollBar">
        <Setter Property="MinWidth" Value="12" />
        <Setter Property="MinHeight" Value="12" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Foreground" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ScrollBar">
                    <Grid x:Name="Root">
                        <Grid.Resources>
                            <ControlTemplate x:Key="RepeatButtonTemplate" TargetType="RepeatButton">
                                <Grid x:Name="Root" Background="Transparent">
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Normal" />
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                </Grid>
                            </ControlTemplate>
                            <ControlTemplate x:Key="HorizontalIncrementTemplate" TargetType="RepeatButton">
                                <Grid x:Name="Root">
                                    <FontIcon
                                        x:Name="Arrow"
                                        FontFamily="{ThemeResource SymbolThemeFontFamily}"
                                        FontSize="6"
                                        Foreground="{ThemeResource SystemControlForegroundBaseHighBrush}"
                                        Glyph="&#xE0E3;"
                                        MirroredWhenRightToLeft="True" />
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Normal" />
                                            <VisualState x:Name="PointerOver">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Background">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumLowBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Arrow" Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Pressed">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Background">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Arrow" Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltAltHighBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Disabled">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Arrow" Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseHighBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                </Grid>
                            </ControlTemplate>
                            <ControlTemplate x:Key="HorizontalDecrementTemplate" TargetType="RepeatButton">
                                <Grid x:Name="Root">
                                    <FontIcon
                                        x:Name="Arrow"
                                        FontFamily="{ThemeResource SymbolThemeFontFamily}"
                                        FontSize="6"
                                        Foreground="{ThemeResource SystemControlForegroundBaseHighBrush}"
                                        Glyph="&#xE0E2;"
                                        MirroredWhenRightToLeft="True" />
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Normal" />
                                            <VisualState x:Name="PointerOver">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Background">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumLowBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Arrow" Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Pressed">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Background">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Arrow" Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltAltHighBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Disabled">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Arrow" Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseHighBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                </Grid>
                            </ControlTemplate>
                            <ControlTemplate x:Key="VerticalIncrementTemplate" TargetType="RepeatButton">
                                <Grid x:Name="Root">
                                    <FontIcon
                                        x:Name="Arrow"
                                        FontFamily="{ThemeResource SymbolThemeFontFamily}"
                                        FontSize="6"
                                        Foreground="{ThemeResource SystemControlForegroundBaseHighBrush}"
                                        Glyph="&#xE0E5;" />
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Normal" />
                                            <VisualState x:Name="PointerOver">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Background">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumLowBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Arrow" Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Pressed">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Background">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Arrow" Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltAltHighBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Disabled">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Arrow" Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseHighBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                </Grid>
                            </ControlTemplate>
                            <ControlTemplate x:Key="VerticalDecrementTemplate" TargetType="RepeatButton">
                                <Grid x:Name="Root">
                                    <FontIcon
                                        x:Name="Arrow"
                                        FontFamily="{ThemeResource SymbolThemeFontFamily}"
                                        FontSize="6"
                                        Foreground="{ThemeResource SystemControlForegroundBaseHighBrush}"
                                        Glyph="&#xE0E4;" />
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Normal" />
                                            <VisualState x:Name="PointerOver">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Background">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumLowBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Arrow" Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Pressed">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Background">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Arrow" Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltAltHighBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Disabled">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Arrow" Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseHighBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                </Grid>
                            </ControlTemplate>
                            <ControlTemplate x:Key="VerticalThumbTemplate" TargetType="Thumb">
                                <Rectangle
                                    x:Name="ThumbVisual"
                                    Fill="{ThemeResource SystemControlForegroundBaseLowBrush}"
                                    RadiusX="5"
                                    RadiusY="5">
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Normal" />
                                            <VisualState x:Name="PointerOver">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ThumbVisual" Storyboard.TargetProperty="Fill">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumLowBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Pressed">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ThumbVisual" Storyboard.TargetProperty="Fill">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Disabled">
                                                <Storyboard>
                                                    <DoubleAnimation
                                                        Storyboard.TargetName="ThumbVisual"
                                                        Storyboard.TargetProperty="Opacity"
                                                        To="0"
                                                        Duration="0" />
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                </Rectangle>
                            </ControlTemplate>
                            <ControlTemplate x:Key="HorizontalThumbTemplate" TargetType="Thumb">
                                <Rectangle
                                    x:Name="ThumbVisual"
                                    Fill="{ThemeResource SystemControlForegroundBaseLowBrush}"
                                    RadiusX="5"
                                    RadiusY="5">
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Normal" />
                                            <VisualState x:Name="PointerOver">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ThumbVisual" Storyboard.TargetProperty="Fill">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumLowBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Pressed">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ThumbVisual" Storyboard.TargetProperty="Fill">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Disabled">
                                                <Storyboard>
                                                    <DoubleAnimation
                                                        Storyboard.TargetName="ThumbVisual"
                                                        Storyboard.TargetProperty="Opacity"
                                                        To="0"
                                                        Duration="0" />
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                </Rectangle>
                            </ControlTemplate>
                        </Grid.Resources>
                        <Grid x:Name="HorizontalRoot" IsHitTestVisible="False">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Rectangle
                                x:Name="HorizontalTrackRect"
                                Grid.ColumnSpan="5"
                                Height="7"
                                Margin="0"
                                Fill="Transparent"
                                RadiusX="5"
                                RadiusY="5"
                                Stroke="{ThemeResource SystemControlForegroundTransparentBrush}"
                                StrokeThickness="{ThemeResource ScrollBarTrackBorderThemeThickness}" />
                            <RepeatButton
                                x:Name="HorizontalSmallDecrease"
                                Grid.Column="0"
                                Width="12"
                                MinHeight="12"
                                Margin="0"
                                VerticalAlignment="Center"
                                Interval="50"
                                IsTabStop="False"
                                Opacity="0"
                                Template="{StaticResource HorizontalDecrementTemplate}" />
                            <RepeatButton
                                x:Name="HorizontalLargeDecrease"
                                Grid.Column="1"
                                Width="0"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Interval="50"
                                IsTabStop="False"
                                Opacity="0"
                                Template="{StaticResource RepeatButtonTemplate}" />
                            <Thumb
                                x:Name="HorizontalThumb"
                                Grid.Column="2"
                                Height="7"
                                MinWidth="12"
                                AutomationProperties.AccessibilityView="Raw"
                                Background="{ThemeResource SystemControlForegroundChromeHighBrush}"
                                Template="{StaticResource HorizontalThumbTemplate}" />
                            <RepeatButton
                                x:Name="HorizontalLargeIncrease"
                                Grid.Column="3"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Interval="50"
                                IsTabStop="False"
                                Opacity="0"
                                Template="{StaticResource RepeatButtonTemplate}" />
                            <RepeatButton
                                x:Name="HorizontalSmallIncrease"
                                Grid.Column="4"
                                Width="12"
                                MinHeight="12"
                                Margin="0"
                                VerticalAlignment="Center"
                                Interval="50"
                                IsTabStop="False"
                                Opacity="0"
                                Template="{StaticResource HorizontalIncrementTemplate}" />
                        </Grid>
                        <Grid x:Name="HorizontalPanningRoot" MinWidth="24">
                            <Border
                                x:Name="HorizontalPanningThumb"
                                Height="2"
                                MinWidth="32"
                                Margin="0,2,0,2"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Bottom"
                                Background="{ThemeResource SystemControlForegroundChromeDisabledLowBrush}"
                                BorderThickness="0" />
                        </Grid>
                        <Grid x:Name="VerticalRoot" IsHitTestVisible="False">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Rectangle
                                x:Name="VerticalTrackRect"
                                Grid.RowSpan="5"
                                Height="7"
                                Margin="0"
                                RadiusX="5"
                                RadiusY="5"
                                Stroke="{ThemeResource SystemControlForegroundTransparentBrush}"
                                StrokeThickness="{ThemeResource ScrollBarTrackBorderThemeThickness}" />
                            <RepeatButton
                                x:Name="VerticalSmallDecrease"
                                Grid.Row="0"
                                Height="12"
                                MinWidth="12"
                                Margin="0"
                                HorizontalAlignment="Center"
                                Interval="50"
                                IsHitTestVisible="False"
                                IsTabStop="False"
                                Opacity="0"
                                Template="{StaticResource VerticalDecrementTemplate}" />
                            <RepeatButton
                                x:Name="VerticalLargeDecrease"
                                Grid.Row="1"
                                Height="0"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Interval="50"
                                IsHitTestVisible="False"
                                IsTabStop="False"
                                Opacity="0"
                                Template="{StaticResource RepeatButtonTemplate}" />
                            <Thumb
                                x:Name="VerticalThumb"
                                Grid.Row="2"
                                Width="7"
                                MinHeight="12"
                                AutomationProperties.AccessibilityView="Raw"
                                Background="#FFEAEAEA"
                                Template="{StaticResource VerticalThumbTemplate}" />
                            <RepeatButton
                                x:Name="VerticalLargeIncrease"
                                Grid.Row="3"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Interval="50"
                                IsHitTestVisible="False"
                                IsTabStop="False"
                                Opacity="0"
                                Template="{StaticResource RepeatButtonTemplate}" />
                            <RepeatButton
                                x:Name="VerticalSmallIncrease"
                                Grid.Row="4"
                                Height="12"
                                MinWidth="12"
                                Margin="0"
                                HorizontalAlignment="Center"
                                Interval="50"
                                IsHitTestVisible="False"
                                IsTabStop="False"
                                Opacity="0"
                                Template="{StaticResource VerticalIncrementTemplate}" />
                        </Grid>
                        <Grid x:Name="VerticalPanningRoot" MinHeight="24">
                            <Border
                                x:Name="VerticalPanningThumb"
                                Width="2"
                                MinHeight="32"
                                Margin="2,0,2,0"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Top"
                                Background="#FFEAEAEA"
                                BorderThickness="0" />
                        </Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="PointerOver" />
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation
                                            Storyboard.TargetName="Root"
                                            Storyboard.TargetProperty="Opacity"
                                            To="0.5"
                                            Duration="0" />
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalTrackRect" Storyboard.TargetProperty="Stroke">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledTransparentBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="VerticalTrackRect" Storyboard.TargetProperty="Stroke">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledTransparentBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalPanningThumb" Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledChromeHighBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ScrollingIndicatorStates">
                                <VisualState x:Name="TouchIndicator">
                                    <Storyboard>
                                        <FadeInThemeAnimation TargetName="HorizontalPanningRoot" />
                                        <FadeInThemeAnimation TargetName="VerticalPanningRoot" />
                                        <FadeOutThemeAnimation TargetName="HorizontalRoot" />
                                        <FadeOutThemeAnimation TargetName="VerticalRoot" />
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="HorizontalRoot"
                                            Storyboard.TargetProperty="Visibility"
                                            Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="VerticalRoot"
                                            Storyboard.TargetProperty="Visibility"
                                            Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseIndicator">
                                    <Storyboard>
                                        <FadeInThemeAnimation TargetName="HorizontalRoot" />
                                        <FadeInThemeAnimation TargetName="VerticalRoot" />
                                        <FadeOutThemeAnimation TargetName="HorizontalPanningRoot" />
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="HorizontalPanningRoot"
                                            Storyboard.TargetProperty="Visibility"
                                            Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <FadeOutThemeAnimation TargetName="VerticalPanningRoot" />
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="VerticalPanningRoot"
                                            Storyboard.TargetProperty="Visibility"
                                            Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalRoot" Storyboard.TargetProperty="IsHitTestVisible">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <x:Boolean>True</x:Boolean>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="VerticalRoot" Storyboard.TargetProperty="IsHitTestVisible">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <x:Boolean>True</x:Boolean>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="NoIndicator">
                                    <Storyboard>
                                        <FadeOutThemeAnimation BeginTime="0" TargetName="HorizontalPanningRoot" />
                                        <FadeOutThemeAnimation BeginTime="0" TargetName="VerticalPanningRoot" />
                                        <FadeOutThemeAnimation BeginTime="0" TargetName="HorizontalRoot" />
                                        <FadeOutThemeAnimation BeginTime="0" TargetName="VerticalRoot" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

 

 这段神秘代码可以应用在ScrollViewer, ListView, TextBox(多行),GridView等等。

以上是关于UWP 滚动条私人定制的主要内容,如果未能解决你的问题,请参考以下文章

UWP TextBox私人定制

UWP TextBox私人定制

uwp - RichEditBox - 滚动至光标位置,解决行数超出后设置颜色滚动条回滚顶部的问题

2019-11-29-win10-uwp-如何判断一个控件在滚动条的里面是用户可见

Firefox和IE滚动条的定制设计[重复]

如何在 MS Word 文档中显示代码片段,因为它在 *** 中显示(滚动条和灰色背景)