I have to insert image in xaml, that if the thumb is on top it has to be like 1st image , the second image show, how it has to look like if thumb is in the middle, and 3rd - thumb in the bottom. So how to do it? Already I put two images (Yellow arrow to Top, Gray arrow to Bottom), but where to put another two (Yellow arrow to Bottom, Gray arrow to Top)? My code so far:
<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>
I would recommend you to do the following things:
Also I would recommend you to use DrawingImages (vector graphics) instead of PNG, but it's up to you.
Example
And here's converter code:
All you need to do now is to change Content of Repeat buttons and Values in DataTriggers to ones you want.
Hope, it helps.