UWP 滚动条私人定制

简介: 原文: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等等。

目录
相关文章
|
C#
【WPF】使用Popup控件做浮窗/提示框
原文:【WPF】使用Popup控件做浮窗/提示框 需求:当鼠标移入某个区域时,弹出一个浮窗,以便用户进行下一步操作。 效果如下图: 当鼠标移入左上角的【多选显示】框内,出现下面的浮窗(悬浮在原UI之上)。
4228 0
|
Windows
[UWP]使用AdaptiveTrigger实现自适应布局
原文:[UWP]使用AdaptiveTrigger实现自适应布局 这篇博客将介绍如何在UWP开发中使用AdaptiveTrigger实现自适应布局。 场景1:窗体宽度大于800时,窗体背景色为绿色,窗体在0到800之间为蓝色。
986 0
|
C#
WPF中制作无边框窗体
原文:WPF中制作无边框窗体 众所周知,在WinForm中,如果要制作一个无边框窗体,可以将窗体的FormBorderStyle属性设置为None来完成。
1476 0
|
C#
WPF 可触摸移动的ScrollViewer控件
原文:WPF 可触摸移动的ScrollViewer控件 ListBox支持触摸滑动,而ScrollViewer默认不支持。 ScrollViewer如需要添加上下/左右触摸移动,需要在Touch事件中处理。
1863 0
|
C#
WPF 动画显示控件
原文:WPF 动画显示控件    当我们要显示一个控件的时候,不仅仅要显示这个控件,还要有动画的效果。    主要用到了DoubleAnimation类。 public static void ShowAnimation(object control) { Type type = control.
1307 0
|
C# Windows Web App开发
WPF 应用完全模拟 UWP 的标题栏按钮
原文:WPF 应用完全模拟 UWP 的标题栏按钮 版权声明:本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。欢迎转载、使用、重新发布,但务必保留文章署名吕毅(包含链接:http://blog.csdn.net/wpwalter/),不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。
1043 0
|
C#
WPF无边框拖动、全屏、缩放
原文:WPF无边框拖动、全屏、缩放 版权声明:本文为博主原创文章,转载请注明出处。 https://blog.csdn.net/lwwl12/article/details/78059361 先看效果 无边框 设置WindowStyle=”None”,窗口无关闭及缩放按钮,但还有黑边;设置AllowsTransparency=”True”,黑边没有了。
1988 0
|
前端开发 C# Windows
WPF控件拖动
原文:WPF控件拖动 这篇博文总结下WPF中的拖动,文章内容主要包括: 1.拖动窗口 2.拖动控件 Using Visual Studio   2.1thumb控件   2.2Drag、Drop(不连续,没有中间动画)   2.3拖动一个控件   2.4让一个窗口内的所有(指定的)控件可拖动 3.Expression Blend X实现拖动(Best Practice) 小结 1.拖动窗口                         我们知道,鼠标放在窗口的标题栏上按下就可以拖动窗体。
2183 0
|
C# Windows
WPF实用指南一:在WPF窗体的边框中添加搜索框和按钮
原文:WPF实用指南一:在WPF窗体的边框中添加搜索框和按钮 在边框中加入一些元素,在应用程序的界面设计中,已经开始流行起来。
1283 0
|
C#
关于wpf中popup跟随鼠标移动显示
原文:关于wpf中popup跟随鼠标移动显示 最近在做一个画图工具,里面有一个功能是需要实现,当鼠标移动的时候在,鼠标的旁边显示坐标信息。 第一反应是想到了tooltip,但是tooltip有许多的限制,查询资料的过程中看到了popup,popup比tooltip更加灵活,下面讲讲tooltip跟popup的区别: 1.tooltip会自动显示,自动隐藏,而popup则需要设置IsOpen属性,并且在Popup.StaysOen属性为true时,Popup控件会一直显示,直到显式地将IsOpen属性设置为False。
1931 0

热门文章

最新文章