ScrollViewer.xaml 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:hc="clr-namespace:HandyControl.Controls">
  4. <!--default style-->
  5. <Style BasedOn="{StaticResource ScrollViewerNativeBaseStyle}" TargetType="ScrollViewer"/>
  6. <Style BasedOn="{StaticResource ScrollViewerBaseStyle}" TargetType="hc:ScrollViewer"/>
  7. <Style x:Key="ScrollViewerUpDownRepeatButtonStyle" BasedOn="{StaticResource RepeatButtonIcon}" TargetType="RepeatButton">
  8. <Setter Property="HorizontalAlignment" Value="Stretch"/>
  9. <Setter Property="Height" Value="10"/>
  10. <Setter Property="Padding" Value="0,2"/>
  11. <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
  12. <Setter Property="ClickMode" Value="Hover"/>
  13. </Style>
  14. <ControlTemplate x:Key="ScrollViewerUpDownControlTemplate" TargetType="ScrollViewer">
  15. <Grid x:Name="Grid" Background="{TemplateBinding Background}">
  16. <Grid.RowDefinitions>
  17. <RowDefinition Height="Auto"/>
  18. <RowDefinition/>
  19. <RowDefinition Height="Auto"/>
  20. </Grid.RowDefinitions>
  21. <RepeatButton Style="{StaticResource ScrollViewerUpDownRepeatButtonStyle}" hc:IconElement.Geometry="{StaticResource UpGeometry}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Command="{x:Static ScrollBar.LineUpCommand}">
  22. <RepeatButton.Visibility>
  23. <MultiBinding FallbackValue="Visibility.Collapsed" Converter="{StaticResource MenuScrollingVisibilityConverter}" ConverterParameter="0">
  24. <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ComputedVerticalScrollBarVisibility" />
  25. <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="VerticalOffset" />
  26. <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ExtentHeight" />
  27. <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ViewportHeight" />
  28. </MultiBinding>
  29. </RepeatButton.Visibility>
  30. </RepeatButton>
  31. <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="1"/>
  32. <RepeatButton Style="{StaticResource ScrollViewerUpDownRepeatButtonStyle}" hc:IconElement.Geometry="{StaticResource DownGeometry}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Grid.Row="2" Command="{x:Static ScrollBar.LineDownCommand}">
  33. <RepeatButton.Visibility>
  34. <MultiBinding FallbackValue="Visibility.Collapsed" Converter="{StaticResource MenuScrollingVisibilityConverter}" ConverterParameter="100">
  35. <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ComputedVerticalScrollBarVisibility" />
  36. <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="VerticalOffset" />
  37. <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ExtentHeight" />
  38. <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ViewportHeight" />
  39. </MultiBinding>
  40. </RepeatButton.Visibility>
  41. </RepeatButton>
  42. </Grid>
  43. </ControlTemplate>
  44. <Style x:Key="ScrollViewerUpDown" TargetType="ScrollViewer">
  45. <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
  46. <Setter Property="Focusable" Value="False"/>
  47. <Setter Property="Template" Value="{StaticResource ScrollViewerUpDownControlTemplate}"/>
  48. </Style>
  49. </ResourceDictionary>