Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: C#  |  size: 4.66 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!-- App.xaml's Application.Resources -->
  2.  
  3. <!-- ScrollBarThumb -->
  4. <Style x:Key="ScrollBarThumb"
  5.         TargetType="{x:Type Thumb}">
  6.         <Setter Property="OverridesDefaultStyle"
  7.                 Value="true"/>
  8.         <Setter Property="IsTabStop"
  9.                 Value="false"/>
  10.         <Setter Property="Template">
  11.                 <Setter.Value>
  12.                         <ControlTemplate TargetType="{x:Type Thumb}">
  13.                                 <Border Background="#FF777777" CornerRadius="2"/>
  14.                         </ControlTemplate>
  15.                 </Setter.Value>
  16.         </Setter>
  17. </Style>
  18.  
  19. <!-- ScrollBar -->
  20. <Style x:Key="{x:Type ScrollBar}"
  21.   TargetType="{x:Type ScrollBar}">
  22.         <Setter Property="Background" Value="#FF979797"/>
  23.         <Style.Triggers>
  24.                 <Trigger Property="Orientation" Value="Vertical">
  25.                         <Setter Property="Template">
  26.                                 <Setter.Value>
  27.                                         <ControlTemplate TargetType="{x:Type ScrollBar}">
  28.                                                 <Border CornerRadius="4" Margin="2" Opacity="0.75" Background="{TemplateBinding Background}">
  29.                                                         <Grid SnapsToDevicePixels="true">
  30.                                                                 <Grid.RowDefinitions>
  31.                                                                         <RowDefinition Height="0.00001*"/>
  32.                                                                 </Grid.RowDefinitions>
  33.                                                                 <Track Name="PART_Track" IsDirectionReversed="true">
  34.                                                                         <Track.Thumb>
  35.                                                                                 <Thumb Style="{StaticResource ScrollBarThumb}" theme:ScrollChrome.ScrollGlyph="VerticalGripper" Margin="2"/>
  36.                                                                         </Track.Thumb>
  37.                                                                 </Track>
  38.                                                         </Grid>
  39.                                                 </Border>
  40.                                         </ControlTemplate>
  41.                                 </Setter.Value>
  42.                         </Setter>
  43.                 </Trigger>
  44.  
  45.                 <Trigger Property="Orientation" Value="Horizontal">
  46.                         <Setter Property="Template">
  47.                                 <Setter.Value>
  48.                                         <ControlTemplate TargetType="{x:Type ScrollBar}">
  49.                                                 <Border CornerRadius="4" Margin="2" Opacity="0.75" Background="{TemplateBinding Background}">
  50.                                                         <Grid SnapsToDevicePixels="true">
  51.                                                                 <Grid.ColumnDefinitions>
  52.                                                                         <ColumnDefinition Width="0.00001*"/>
  53.                                                                 </Grid.ColumnDefinitions>
  54.                                                                 <Track Name="PART_Track" IsEnabled="{TemplateBinding IsMouseOver}">
  55.                                                                         <Track.Thumb>
  56.                                                                                 <Thumb x:Name="Thumb" Style="{StaticResource ScrollBarThumb}" theme:ScrollChrome.ScrollGlyph="HorizontalGripper" Margin="2"/>
  57.                                                                         </Track.Thumb>
  58.                                                                 </Track>
  59.                                                         </Grid>
  60.                                                 </Border>
  61.                                         </ControlTemplate>
  62.                                 </Setter.Value>
  63.                         </Setter>
  64.                 </Trigger>
  65.         </Style.Triggers>
  66. </Style>
  67.  
  68. <!-- ScrollViewer -->
  69. <Style x:Key="{x:Type ScrollViewer}"
  70.   TargetType="{x:Type ScrollViewer}">
  71.         <Setter Property="HorizontalScrollBarVisibility" Value="Hidden"/>
  72.         <Setter Property="VerticalScrollBarVisibility" Value="Hidden"/>
  73.         <Setter Property="Template">
  74.                 <Setter.Value>
  75.                         <ControlTemplate TargetType="{x:Type ScrollViewer}">
  76.                                 <Grid>
  77.                                         <Grid Background="{TemplateBinding Background}">
  78.                                                 <ScrollContentPresenter
  79.                                                         x:Name="PART_ScrollContentPresenter"
  80.                                                         Margin="{TemplateBinding Padding}"
  81.                                                         Content="{TemplateBinding Content}"
  82.                                                         ContentTemplate="{TemplateBinding ContentTemplate}"
  83.                                                         CanContentScroll="{TemplateBinding CanContentScroll}"/>
  84.                                         </Grid>
  85.                                         <Grid Background="Transparent">
  86.                                                 <Grid.ColumnDefinitions>
  87.                                                         <ColumnDefinition Width="*"/>
  88.                                                         <ColumnDefinition Width="Auto"/>
  89.                                                 </Grid.ColumnDefinitions>
  90.                                                 <Grid.RowDefinitions>
  91.                                                         <RowDefinition Height="*"/>
  92.                                                         <RowDefinition Height="Auto"/>
  93.                                                 </Grid.RowDefinitions>
  94.                                                 <ScrollBar
  95.                                                         x:Name="PART_VerticalScrollBar"
  96.                                                         Grid.Column="1"
  97.                                                         Minimum="0.0"
  98.                                                         Maximum="{TemplateBinding ScrollableHeight}"
  99.                                                         ViewportSize="{TemplateBinding ViewportHeight}"
  100.                                                         Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=VerticalOffset, Mode=OneWay}"
  101.                                                         Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"        
  102.                                                         Cursor="Arrow"
  103.                                                         AutomationProperties.AutomationId="VerticalScrollBar"/>
  104.                                                 <ScrollBar
  105.                                                         x:Name="PART_HorizontalScrollBar"
  106.                                                         Orientation="Horizontal"
  107.                                                         Grid.Row="1"
  108.                                                         Minimum="0.0"
  109.                                                         Maximum="{TemplateBinding ScrollableWidth}"
  110.                                                         ViewportSize="{TemplateBinding ViewportWidth}"
  111.                                                         Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=HorizontalOffset, Mode=OneWay}"
  112.                                                         Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
  113.                                                         Cursor="Arrow"
  114.                                                         AutomationProperties.AutomationId="HorizontalScrollBar"/>
  115.                                         </Grid>
  116.                                 </Grid>
  117.                         </ControlTemplate>
  118.                 </Setter.Value>
  119.         </Setter>
  120.         <Style.Triggers>
  121.                 <Trigger Property="IsEnabled"
  122.                          Value="false">
  123.                         <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  124.                 </Trigger>
  125.                 <Trigger Property="IsMouseOver" Value="true">
  126.                         <Setter Property="HorizontalScrollBarVisibility" Value="Auto"/>
  127.                         <Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
  128.                 </Trigger>
  129.         </Style.Triggers>
  130. </Style>