我必须在 xaml 中插入图像,如果拇指在顶部,它必须像第一个图像,第二个图像显示,如果拇指在中间,第三个拇指在底部,它的外观如何。那么该怎么做呢?我已经放了两个图像(黄色箭头到顶部,灰色箭头到底部),但是在哪里放置另外两个(黄色箭头到底部,灰色箭头到顶部)?到目前为止我的代码:
<Window x:Class="Scroll4.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<SolidColorBrush x:Key="Background" Color="Gray" />
<Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Border Background="Transparent" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
<Setter Property="Panel.ZIndex" Value="1" />
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="Opacity" Value="0.7" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border Name="Border"
CornerRadius="3"
Background="{StaticResource Background}"
BorderBrush="Transparent"
BorderThickness="1" />
<ControlTemplate.Triggers>
<Trigger Property="IsDragging" Value="true">
<Setter TargetName="Border" Property="Background" Value="{StaticResource Background}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition MaxHeight="60"/>
<RowDefinition Height="*"/>
<RowDefinition MaxHeight="60"/>
</Grid.RowDefinitions>
<Border
Grid.RowSpan="3"
CornerRadius="2"
Background="#F8F8F8"/>
<RepeatButton
Focusable="False" Content="Up"
Height="60"
Command="ScrollBar.LineUpCommand">
<RepeatButton.Template>
<ControlTemplate>
<DockPanel>
<Image Source="/Scroll4;component/Resources/bg.slide-up-active.png"/>
<ContentPresenter/>
</DockPanel>
</ControlTemplate>
</RepeatButton.Template>
</RepeatButton>
<Track
Name="PART_Track"
Grid.Row="1"
IsDirectionReversed="True">
<Track.DecreaseRepeatButton>
<RepeatButton
Style="{StaticResource ScrollBarPageButton}"
Margin="3,2,3,2"
Command="ScrollBar.PageUpCommand"/>
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource ScrollBarThumb}">
</Thumb>
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton
Style="{StaticResource ScrollBarPageButton}"
Margin="3,2,3,2"
Command="ScrollBar.PageDownCommand" />
</Track.IncreaseRepeatButton>
</Track>
<RepeatButton
Grid.Row="2"
Focusable="False"
Height="60"
Command="ScrollBar.LineDownCommand"
Content="Down">
<RepeatButton.Template>
<ControlTemplate>
<DockPanel>
<Image Source="/Scroll4;component/Resources/bg.slide-down-disabled.png"/>
</DockPanel>
</ControlTemplate>
</RepeatButton.Template>
</RepeatButton>
</Grid>
</ControlTemplate>
<Style TargetType="ScrollBar">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Style.Triggers>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="Width" Value="60"/>
<Setter Property="Height" Value="Auto" />
<Setter Property="Template" Value="{StaticResource VerticalScrollBar}" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid >
<ScrollViewer Margin="89,94,183.4,90.8" RenderTransformOrigin="0.792,0.806" >
<Image Source="/Scroll4;component/Resources/Football_grass.jpg"
Stretch="Fill" Height="500" />
</ScrollViewer>
</Grid>