<Window
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
	x:Class="ScroolBarTemplate.MainWindow"
	x:Name="Window"
	Title="MainWindow"
	Width="640" Height="280">

	<Window.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="ButtonTemplate.xaml"/>
				<ResourceDictionary Source="ResourceDictionary1.xaml"/>
			</ResourceDictionary.MergedDictionaries>
			
			
		
			<Style x:Key="ScrollBarButton" TargetType="{x:Type RepeatButton}">
				<Setter Property="OverridesDefaultStyle" Value="true"/>
				<Setter Property="Focusable" Value="false"/>
				<Setter Property="IsTabStop" Value="false"/>
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate TargetType="{x:Type RepeatButton}">
							<Microsoft_Windows_Themes:ScrollChrome x:Name="Chrome" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}" SnapsToDevicePixels="true" Microsoft_Windows_Themes:ScrollChrome.ScrollGlyph="{TemplateBinding Microsoft_Windows_Themes:ScrollChrome.ScrollGlyph}"/>
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Style>
			<Style x:Key="VerticalScrollBarPageButton" TargetType="{x:Type RepeatButton}">
				<Setter Property="OverridesDefaultStyle" Value="true"/>
				<Setter Property="Background" Value="Transparent"/>
				<Setter Property="Focusable" Value="false"/>
				<Setter Property="IsTabStop" Value="false"/>
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate TargetType="{x:Type RepeatButton}">
							<Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"/>
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Style>
			
			<Style x:Key="ScrollBarStyle1" TargetType="{x:Type ScrollBar}">
				<Setter Property="Background" Value="#B78D8888"/>
				<Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
				<Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
				<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
				<Setter Property="Width" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
				<Setter Property="MinWidth" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate TargetType="{x:Type ScrollBar}">
					
						<Border x:Name="Bg"  CornerRadius="10" Background="{TemplateBinding Background}" >
							<Grid  SnapsToDevicePixels="true">
								<Grid.RowDefinitions>
									<RowDefinition Height="0.00001*"/>
									<RowDefinition MaxHeight="{DynamicResource {x:Static SystemParameters.VerticalScrollBarButtonHeightKey}}"/>
									<RowDefinition MaxHeight="{DynamicResource {x:Static SystemParameters.VerticalScrollBarButtonHeightKey}}"/>
								</Grid.RowDefinitions>								
								<Track x:Name="PART_Track" IsDirectionReversed="true" IsEnabled="{TemplateBinding IsMouseOver}" Grid.Row="0">
									<Track.IncreaseRepeatButton>
										<RepeatButton Command="{x:Static ScrollBar.PageDownCommand}" Style="{StaticResource VerticalScrollBarPageButton}"/>
									</Track.IncreaseRepeatButton>
									<Track.DecreaseRepeatButton>
										<RepeatButton Command="{x:Static ScrollBar.PageDownCommand}" Style="{StaticResource VerticalScrollBarPageButton}"/>
									</Track.DecreaseRepeatButton>
									<Track.Thumb>
										<Thumb Style="{DynamicResource ThumbStyle1}" Microsoft_Windows_Themes:ScrollChrome.ScrollGlyph="VerticalGripper"/>
									</Track.Thumb>
								</Track>
								<RepeatButton Command="{x:Static ScrollBar.LineUpCommand}"  Grid.Row="1" Style="{StaticResource RepeatButtonStyle}"/>
								<RepeatButton Command="{x:Static ScrollBar.LineDownCommand}"  Grid.Row="2" Style="{StaticResource RepeatButtonStyle}"/> 
							</Grid>
							</Border>
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Style>
			<ControlTemplate x:Key="ScrollViewerControlTemplate1" TargetType="{x:Type ScrollViewer}">
				<Grid x:Name="Grid" Background="{TemplateBinding Background}">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="*"/>
						<ColumnDefinition Width="Auto"/>
					</Grid.ColumnDefinitions>
					<Grid.RowDefinitions>
						<RowDefinition Height="*"/>
						<RowDefinition Height="Auto"/>
					</Grid.RowDefinitions>
					<Rectangle x:Name="Corner" Grid.Column="1" Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Grid.Row="1"/>
					<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Margin="{TemplateBinding Padding}" Grid.Row="0"/>
					<ScrollBar x:Name="PART_VerticalScrollBar" Style="{StaticResource ScrollBarStyle1}" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/>
					<ScrollBar x:Name="PART_HorizontalScrollBar" AutomationProperties.AutomationId="HorizontalScrollBar" Cursor="Arrow" Grid.Column="0" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Orientation="Horizontal" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/>
				</Grid>
			</ControlTemplate>
		</ResourceDictionary>
	</Window.Resources>

	<Grid x:Name="LayoutRoot">
		<ScrollViewer Margin="5" Template="{DynamicResource ScrollViewerControlTemplate1}"  >
			<StackPanel Height="450"/>
			<ScrollViewer.LayoutTransform>
				<ScaleTransform ScaleX="2" ScaleY="2"/>
			</ScrollViewer.LayoutTransform>
		</ScrollViewer>
	</Grid>
</Window>