ScrollViewerStyles.axaml 6.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <Styles xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:converters="clr-namespace:SukiUI.Converters">
  4. <Style Selector="ScrollViewer">
  5. <Setter Property="Template">
  6. <ControlTemplate>
  7. <Grid ColumnDefinitions="*,Auto" RowDefinitions="*,Auto">
  8. <ScrollContentPresenter Name="PART_ContentPresenter"
  9. Padding="{TemplateBinding Padding}"
  10. Background="{TemplateBinding Background}"
  11. HorizontalSnapPointsAlignment="{TemplateBinding HorizontalSnapPointsAlignment}"
  12. HorizontalSnapPointsType="{TemplateBinding HorizontalSnapPointsType}"
  13. ScrollViewer.IsScrollInertiaEnabled="{TemplateBinding IsScrollInertiaEnabled}"
  14. VerticalSnapPointsAlignment="{TemplateBinding VerticalSnapPointsAlignment}"
  15. VerticalSnapPointsType="{TemplateBinding VerticalSnapPointsType}">
  16. <ScrollContentPresenter.GestureRecognizers>
  17. <ScrollGestureRecognizer CanHorizontallyScroll="{Binding CanHorizontallyScroll, ElementName=PART_ContentPresenter}"
  18. CanVerticallyScroll="{Binding CanVerticallyScroll, ElementName=PART_ContentPresenter}"
  19. IsScrollInertiaEnabled="{Binding (ScrollViewer.IsScrollInertiaEnabled), ElementName=PART_ContentPresenter}" />
  20. </ScrollContentPresenter.GestureRecognizers>
  21. </ScrollContentPresenter>
  22. <ScrollBar Name="PART_HorizontalScrollBar"
  23. Grid.Row="1"
  24. Grid.Column="0"
  25. Orientation="Horizontal" />
  26. <ScrollBar Name="PART_VerticalScrollBar"
  27. Grid.Row="0"
  28. Grid.Column="1"
  29. Orientation="Vertical" />
  30. <Panel Name="PART_ScrollBarsSeparator"
  31. Grid.Row="1"
  32. Grid.Column="1"
  33. Background="Transparent" />
  34. </Grid>
  35. </ControlTemplate>
  36. </Setter>
  37. </Style>
  38. <Style Selector="ScrollViewer.Stack">
  39. <Setter Property="Background" Value="Transparent" />
  40. <Setter Property="Template">
  41. <ControlTemplate>
  42. <Panel>
  43. <Panel>
  44. <Panel.OpacityMask>
  45. <MultiBinding Converter="{x:Static converters:SideMenuScrollerToOpacityMask.Top}">
  46. <Binding ElementName="PART_VerticalScrollBar" Path="Value" />
  47. <Binding ElementName="PART_VerticalScrollBar" Path="Minimum" />
  48. </MultiBinding>
  49. </Panel.OpacityMask>
  50. <Panel.Transitions>
  51. <Transitions>
  52. <BrushTransition Property="OpacityMask" Duration="{StaticResource ShortAnimationDuration}" />
  53. </Transitions>
  54. </Panel.Transitions>
  55. <ScrollContentPresenter Name="PART_ContentPresenter"
  56. Padding="{TemplateBinding Padding}"
  57. Background="{TemplateBinding Background}"
  58. HorizontalSnapPointsAlignment="{TemplateBinding HorizontalSnapPointsAlignment}"
  59. HorizontalSnapPointsType="{TemplateBinding HorizontalSnapPointsType}"
  60. ScrollViewer.IsScrollInertiaEnabled="{TemplateBinding IsScrollInertiaEnabled}"
  61. VerticalSnapPointsAlignment="{TemplateBinding VerticalSnapPointsAlignment}"
  62. VerticalSnapPointsType="{TemplateBinding VerticalSnapPointsType}">
  63. <ScrollContentPresenter.OpacityMask>
  64. <MultiBinding Converter="{x:Static converters:SideMenuScrollerToOpacityMask.Bottom}">
  65. <Binding ElementName="PART_VerticalScrollBar" Path="Value" />
  66. <Binding ElementName="PART_VerticalScrollBar" Path="Maximum" />
  67. </MultiBinding>
  68. </ScrollContentPresenter.OpacityMask>
  69. <ScrollContentPresenter.Transitions>
  70. <Transitions>
  71. <BrushTransition Property="OpacityMask" Duration="{StaticResource ShortAnimationDuration}" />
  72. </Transitions>
  73. </ScrollContentPresenter.Transitions>
  74. <ScrollContentPresenter.GestureRecognizers>
  75. <ScrollGestureRecognizer CanHorizontallyScroll="{Binding CanHorizontallyScroll, ElementName=PART_ContentPresenter}"
  76. CanVerticallyScroll="{Binding CanVerticallyScroll, ElementName=PART_ContentPresenter}"
  77. IsScrollInertiaEnabled="{Binding (ScrollViewer.IsScrollInertiaEnabled), ElementName=PART_ContentPresenter}" />
  78. </ScrollContentPresenter.GestureRecognizers>
  79. </ScrollContentPresenter>
  80. </Panel>
  81. <ScrollBar Name="PART_VerticalScrollBar"
  82. HorizontalAlignment="Stretch"
  83. VerticalAlignment="Stretch"
  84. Classes="Stack"
  85. Orientation="Vertical" />
  86. </Panel>
  87. </ControlTemplate>
  88. </Setter>
  89. <Style Selector="^ /template/ ScrollContentPresenter" />
  90. </Style>
  91. </Styles>