Browse Source
Including splitting out the menu scroller into a separate xaml file for separate preview.pull/8479/head
4 changed files with 204 additions and 87 deletions
@ -0,0 +1,98 @@ |
|||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls"> |
||||
|
|
||||
|
<Design.PreviewWith> |
||||
|
<ScrollViewer Theme="{DynamicResource FluentMenuScrollViewer}" Width="200" Height="200"> |
||||
|
<StackPanel Spacing="20"> |
||||
|
<TextBlock>Item 1</TextBlock> |
||||
|
<TextBlock>Item 2</TextBlock> |
||||
|
<TextBlock>Item 3</TextBlock> |
||||
|
<TextBlock>Item 4</TextBlock> |
||||
|
<TextBlock>Item 5</TextBlock> |
||||
|
<TextBlock>Item 6</TextBlock> |
||||
|
<TextBlock>Item 7</TextBlock> |
||||
|
<TextBlock>Item 8</TextBlock> |
||||
|
<TextBlock>Item 9</TextBlock> |
||||
|
</StackPanel> |
||||
|
</ScrollViewer> |
||||
|
</Design.PreviewWith> |
||||
|
|
||||
|
<ControlTheme x:Key="FluentMenuScrollViewer" TargetType="ScrollViewer"> |
||||
|
<Setter Property="Background" Value="Transparent" /> |
||||
|
<Setter Property="Template"> |
||||
|
<ControlTemplate> |
||||
|
<DockPanel> |
||||
|
<RepeatButton DockPanel.Dock="Top" |
||||
|
BorderThickness="0" |
||||
|
Background="Transparent" |
||||
|
HorizontalAlignment="Stretch" |
||||
|
HorizontalContentAlignment="Center" |
||||
|
RenderTransform="{x:Null}" |
||||
|
Command="{Binding LineUp, RelativeSource={RelativeSource TemplatedParent}}"> |
||||
|
<RepeatButton.IsVisible> |
||||
|
<MultiBinding Converter="{x:Static converters:MenuScrollingVisibilityConverter.Instance}" |
||||
|
ConverterParameter="0"> |
||||
|
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="VerticalScrollBarVisibility" /> |
||||
|
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Offset.Y" /> |
||||
|
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Extent.Height" /> |
||||
|
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Viewport.Height" /> |
||||
|
</MultiBinding> |
||||
|
</RepeatButton.IsVisible> |
||||
|
<Viewbox Width="{DynamicResource ScrollBarButtonArrowIconFontSize}" |
||||
|
Height="{DynamicResource ScrollBarButtonArrowIconFontSize}"> |
||||
|
<Path VerticalAlignment="Center" |
||||
|
HorizontalAlignment="Center" |
||||
|
Data="M 19.091797 14.970703 L 10 5.888672 L 0.908203 14.970703 L 0.029297 14.091797 L 10 4.111328 L 19.970703 14.091797 Z" |
||||
|
Fill="{DynamicResource ScrollBarButtonArrowForeground}" |
||||
|
Width="20" |
||||
|
Height="20" /> |
||||
|
</Viewbox> |
||||
|
</RepeatButton> |
||||
|
<RepeatButton DockPanel.Dock="Bottom" |
||||
|
BorderThickness="0" |
||||
|
Background="Transparent" |
||||
|
HorizontalAlignment="Stretch" |
||||
|
HorizontalContentAlignment="Center" |
||||
|
RenderTransform="{x:Null}" |
||||
|
Command="{Binding LineDown, RelativeSource={RelativeSource TemplatedParent}}"> |
||||
|
<RepeatButton.IsVisible> |
||||
|
<MultiBinding Converter="{x:Static converters:MenuScrollingVisibilityConverter.Instance}" |
||||
|
ConverterParameter="100"> |
||||
|
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="VerticalScrollBarVisibility" /> |
||||
|
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Offset.Y" /> |
||||
|
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Extent.Height" /> |
||||
|
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Viewport.Height" /> |
||||
|
</MultiBinding> |
||||
|
</RepeatButton.IsVisible> |
||||
|
<Viewbox Width="{DynamicResource ScrollBarButtonArrowIconFontSize}" |
||||
|
Height="{DynamicResource ScrollBarButtonArrowIconFontSize}"> |
||||
|
<Path VerticalAlignment="Center" |
||||
|
HorizontalAlignment="Center" |
||||
|
Data="M 18.935547 4.560547 L 19.814453 5.439453 L 10 15.253906 L 0.185547 5.439453 L 1.064453 4.560547 L 10 13.496094 Z" |
||||
|
Fill="{DynamicResource ScrollBarButtonArrowForeground}" |
||||
|
Width="20" |
||||
|
Height="20" /> |
||||
|
</Viewbox> |
||||
|
</RepeatButton> |
||||
|
<ScrollContentPresenter Name="PART_ContentPresenter" |
||||
|
CanHorizontallyScroll="{TemplateBinding CanHorizontallyScroll}" |
||||
|
CanVerticallyScroll="{TemplateBinding CanVerticallyScroll}" |
||||
|
Content="{TemplateBinding Content}" |
||||
|
Extent="{TemplateBinding Extent, Mode=TwoWay}" |
||||
|
Margin="{TemplateBinding Padding}" |
||||
|
Offset="{TemplateBinding Offset, Mode=TwoWay}" |
||||
|
Viewport="{TemplateBinding Viewport, Mode=TwoWay}"> |
||||
|
<ScrollContentPresenter.GestureRecognizers> |
||||
|
<ScrollGestureRecognizer CanHorizontallyScroll="{TemplateBinding CanHorizontallyScroll}" |
||||
|
CanVerticallyScroll="{TemplateBinding CanVerticallyScroll}" /> |
||||
|
</ScrollContentPresenter.GestureRecognizers> |
||||
|
</ScrollContentPresenter> |
||||
|
</DockPanel> |
||||
|
</ControlTemplate> |
||||
|
</Setter> |
||||
|
<Style Selector="^ /template/ RepeatButton:pointerover > Viewbox > Path"> |
||||
|
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForegroundPointerOver}" /> |
||||
|
</Style> |
||||
|
</ControlTheme> |
||||
|
</ResourceDictionary> |
||||
@ -1,87 +1,87 @@ |
|||||
<ResourceDictionary |
<ResourceDictionary |
||||
xmlns="https://github.com/avaloniaui" |
xmlns="https://github.com/avaloniaui" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls"> |
xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls"> |
||||
<Design.PreviewWith> |
<Design.PreviewWith> |
||||
<Grid ColumnDefinitions="*,20,*" Height="300" Width="200" Margin="20"> |
<ScrollViewer Width="200" Height="200" |
||||
<ScrollViewer> |
HorizontalScrollBarVisibility="Auto"> |
||||
<Border Height="1000" Background="#ccc" /> |
<StackPanel Spacing="20" Width="210"> |
||||
</ScrollViewer> |
<TextBlock>Item 1</TextBlock> |
||||
<ScrollViewer Grid.Column="2" Classes="menuscroller"> |
<TextBlock>Item 2</TextBlock> |
||||
<Border Height="1000" Background="#ccc" /> |
<TextBlock>Item 3</TextBlock> |
||||
</ScrollViewer> |
<TextBlock>Item 4</TextBlock> |
||||
</Grid> |
<TextBlock>Item 5</TextBlock> |
||||
</Design.PreviewWith> |
<TextBlock>Item 6</TextBlock> |
||||
|
<TextBlock>Item 7</TextBlock> |
||||
<ControlTheme x:Key="{x:Type ScrollViewer}" TargetType="ScrollViewer"> |
<TextBlock>Item 8</TextBlock> |
||||
<Setter Property="Background" Value="Transparent" /> |
<TextBlock>Item 9</TextBlock> |
||||
<Setter Property="Template"> |
</StackPanel> |
||||
<ControlTemplate> |
</ScrollViewer> |
||||
<Grid ColumnDefinitions="*,Auto" RowDefinitions="*,Auto"> |
</Design.PreviewWith> |
||||
<ScrollContentPresenter Name="PART_ContentPresenter" Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Grid.ColumnSpan="2" Background="{TemplateBinding Background}" CanHorizontallyScroll="{TemplateBinding CanHorizontallyScroll}" CanVerticallyScroll="{TemplateBinding CanVerticallyScroll}" Content="{TemplateBinding Content}" Extent="{TemplateBinding Extent, Mode=TwoWay}" Padding="{TemplateBinding Padding}" Offset="{TemplateBinding Offset, Mode=TwoWay}" Viewport="{TemplateBinding Viewport, Mode=TwoWay}" IsScrollChainingEnabled="{TemplateBinding IsScrollChainingEnabled}"> |
|
||||
<ScrollContentPresenter.GestureRecognizers> |
<ControlTheme x:Key="{x:Type ScrollViewer}" TargetType="ScrollViewer"> |
||||
<ScrollGestureRecognizer CanHorizontallyScroll="{TemplateBinding CanHorizontallyScroll}" CanVerticallyScroll="{TemplateBinding CanVerticallyScroll}" /> |
<Setter Property="Background" Value="Transparent" /> |
||||
</ScrollContentPresenter.GestureRecognizers> |
<Setter Property="Template"> |
||||
</ScrollContentPresenter> |
<ControlTemplate> |
||||
<ScrollBar Name="PART_HorizontalScrollBar" AllowAutoHide="{TemplateBinding AllowAutoHide}" Orientation="Horizontal" LargeChange="{Binding LargeChange.Width, RelativeSource={RelativeSource TemplatedParent}}" SmallChange="{Binding SmallChange.Width, RelativeSource={RelativeSource TemplatedParent}}" Maximum="{TemplateBinding HorizontalScrollBarMaximum}" Value="{TemplateBinding HorizontalScrollBarValue, Mode=TwoWay}" ViewportSize="{TemplateBinding HorizontalScrollBarViewportSize}" Visibility="{TemplateBinding HorizontalScrollBarVisibility}" Grid.Row="1" Focusable="False" /> |
<Grid ColumnDefinitions="*,Auto" RowDefinitions="*,Auto"> |
||||
<ScrollBar Name="PART_VerticalScrollBar" AllowAutoHide="{TemplateBinding AllowAutoHide}" Orientation="Vertical" LargeChange="{Binding LargeChange.Height, RelativeSource={RelativeSource TemplatedParent}}" SmallChange="{Binding SmallChange.Height, RelativeSource={RelativeSource TemplatedParent}}" Maximum="{TemplateBinding VerticalScrollBarMaximum}" Value="{TemplateBinding VerticalScrollBarValue, Mode=TwoWay}" ViewportSize="{TemplateBinding VerticalScrollBarViewportSize}" Visibility="{TemplateBinding VerticalScrollBarVisibility}" Grid.Column="1" Focusable="False" /> |
<ScrollContentPresenter Name="PART_ContentPresenter" |
||||
<Panel x:Name="PART_ScrollBarsSeparator" Grid.Row="1" Grid.Column="1" Background="{DynamicResource ScrollViewerScrollBarsSeparatorBackground}" /> |
Grid.Row="0" |
||||
</Grid> |
Grid.Column="0" |
||||
</ControlTemplate> |
Grid.RowSpan="2" |
||||
|
Grid.ColumnSpan="2" |
||||
|
Background="{TemplateBinding Background}" |
||||
|
CanHorizontallyScroll="{TemplateBinding CanHorizontallyScroll}" |
||||
|
CanVerticallyScroll="{TemplateBinding CanVerticallyScroll}" |
||||
|
Content="{TemplateBinding Content}" |
||||
|
Extent="{TemplateBinding Extent, Mode=TwoWay}" |
||||
|
Padding="{TemplateBinding Padding}" |
||||
|
Offset="{TemplateBinding Offset, Mode=TwoWay}" |
||||
|
Viewport="{TemplateBinding Viewport, Mode=TwoWay}" |
||||
|
IsScrollChainingEnabled="{TemplateBinding IsScrollChainingEnabled}"> |
||||
|
<ScrollContentPresenter.GestureRecognizers> |
||||
|
<ScrollGestureRecognizer CanHorizontallyScroll="{TemplateBinding CanHorizontallyScroll}" |
||||
|
CanVerticallyScroll="{TemplateBinding CanVerticallyScroll}" /> |
||||
|
</ScrollContentPresenter.GestureRecognizers> |
||||
|
</ScrollContentPresenter> |
||||
|
<ScrollBar Name="PART_HorizontalScrollBar" |
||||
|
AllowAutoHide="{TemplateBinding AllowAutoHide}" |
||||
|
Orientation="Horizontal" |
||||
|
LargeChange="{Binding LargeChange.Width, RelativeSource={RelativeSource TemplatedParent}}" |
||||
|
SmallChange="{Binding SmallChange.Width, RelativeSource={RelativeSource TemplatedParent}}" |
||||
|
Maximum="{TemplateBinding HorizontalScrollBarMaximum}" |
||||
|
Value="{TemplateBinding HorizontalScrollBarValue, Mode=TwoWay}" |
||||
|
ViewportSize="{TemplateBinding HorizontalScrollBarViewportSize}" |
||||
|
Visibility="{TemplateBinding HorizontalScrollBarVisibility}" |
||||
|
Grid.Row="1" |
||||
|
Focusable="False" /> |
||||
|
<ScrollBar Name="PART_VerticalScrollBar" |
||||
|
AllowAutoHide="{TemplateBinding AllowAutoHide}" |
||||
|
Orientation="Vertical" |
||||
|
LargeChange="{Binding LargeChange.Height, RelativeSource={RelativeSource TemplatedParent}}" |
||||
|
SmallChange="{Binding SmallChange.Height, RelativeSource={RelativeSource TemplatedParent}}" |
||||
|
Maximum="{TemplateBinding VerticalScrollBarMaximum}" |
||||
|
Value="{TemplateBinding VerticalScrollBarValue, Mode=TwoWay}" |
||||
|
ViewportSize="{TemplateBinding VerticalScrollBarViewportSize}" |
||||
|
Visibility="{TemplateBinding VerticalScrollBarVisibility}" |
||||
|
Grid.Column="1" |
||||
|
Focusable="False" /> |
||||
|
<Panel x:Name="PART_ScrollBarsSeparator" |
||||
|
Grid.Row="1" |
||||
|
Grid.Column="1" |
||||
|
Background="{DynamicResource ScrollViewerScrollBarsSeparatorBackground}" /> |
||||
|
</Grid> |
||||
|
</ControlTemplate> |
||||
|
</Setter> |
||||
|
<Style Selector="^ /template/ Panel#PART_ScrollBarsSeparator"> |
||||
|
<Setter Property="Opacity" Value="0" /> |
||||
|
<Setter Property="Transitions"> |
||||
|
<Transitions> |
||||
|
<DoubleTransition Property="Opacity" Duration="0:0:0.1" /> |
||||
|
</Transitions> |
||||
</Setter> |
</Setter> |
||||
<Style Selector="^ /template/ Panel#PART_ScrollBarsSeparator"> |
</Style> |
||||
<Setter Property="Opacity" Value="0" /> |
<Style Selector="^[IsExpanded=true] /template/ Panel#PART_ScrollBarsSeparator"> |
||||
<Setter Property="Transitions"> |
<Setter Property="Opacity" Value="1" /> |
||||
<Transitions> |
</Style> |
||||
<DoubleTransition Property="Opacity" Duration="0:0:0.1" /> |
</ControlTheme> |
||||
</Transitions> |
|
||||
</Setter> |
|
||||
</Style> |
|
||||
<Style Selector="^[IsExpanded=true] /template/ Panel#PART_ScrollBarsSeparator"> |
|
||||
<Setter Property="Opacity" Value="1" /> |
|
||||
</Style> |
|
||||
<Style Selector="^.menuscroller"> |
|
||||
<Setter Property="Template"> |
|
||||
<ControlTemplate> |
|
||||
<DockPanel> |
|
||||
<RepeatButton DockPanel.Dock="Top" BorderThickness="0" Background="Transparent" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" RenderTransform="{x:Null}" Command="{Binding LineUp, RelativeSource={RelativeSource TemplatedParent}}"> |
|
||||
<RepeatButton.IsVisible> |
|
||||
<MultiBinding Converter="{x:Static converters:MenuScrollingVisibilityConverter.Instance}" ConverterParameter="0"> |
|
||||
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="VerticalScrollBarVisibility" /> |
|
||||
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Offset.Y" /> |
|
||||
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Extent.Height" /> |
|
||||
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Viewport.Height" /> |
|
||||
</MultiBinding> |
|
||||
</RepeatButton.IsVisible> |
|
||||
<Viewbox Width="{DynamicResource ScrollBarButtonArrowIconFontSize}" Height="{DynamicResource ScrollBarButtonArrowIconFontSize}"> |
|
||||
<Path VerticalAlignment="Center" HorizontalAlignment="Center" Data="M 19.091797 14.970703 L 10 5.888672 L 0.908203 14.970703 L 0.029297 14.091797 L 10 4.111328 L 19.970703 14.091797 Z" Width="20" Height="20" /> |
|
||||
</Viewbox> |
|
||||
</RepeatButton> |
|
||||
<RepeatButton DockPanel.Dock="Bottom" BorderThickness="0" Background="Transparent" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" RenderTransform="{x:Null}" Command="{Binding LineDown, RelativeSource={RelativeSource TemplatedParent}}"> |
|
||||
<RepeatButton.IsVisible> |
|
||||
<MultiBinding Converter="{x:Static converters:MenuScrollingVisibilityConverter.Instance}" ConverterParameter="100"> |
|
||||
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="VerticalScrollBarVisibility" /> |
|
||||
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Offset.Y" /> |
|
||||
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Extent.Height" /> |
|
||||
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Viewport.Height" /> |
|
||||
</MultiBinding> |
|
||||
</RepeatButton.IsVisible> |
|
||||
<Viewbox Width="{DynamicResource ScrollBarButtonArrowIconFontSize}" Height="{DynamicResource ScrollBarButtonArrowIconFontSize}"> |
|
||||
<Path VerticalAlignment="Center" HorizontalAlignment="Center" Data="M 18.935547 4.560547 L 19.814453 5.439453 L 10 15.253906 L 0.185547 5.439453 L 1.064453 4.560547 L 10 13.496094 Z" Width="20" Height="20" /> |
|
||||
</Viewbox> |
|
||||
</RepeatButton> |
|
||||
<ScrollContentPresenter Name="PART_ContentPresenter" CanHorizontallyScroll="{TemplateBinding CanHorizontallyScroll}" CanVerticallyScroll="{TemplateBinding CanVerticallyScroll}" Content="{TemplateBinding Content}" Extent="{TemplateBinding Extent, Mode=TwoWay}" Margin="{TemplateBinding Padding}" Offset="{TemplateBinding Offset, Mode=TwoWay}" Viewport="{TemplateBinding Viewport, Mode=TwoWay}" /> |
|
||||
</DockPanel> |
|
||||
</ControlTemplate> |
|
||||
</Setter> |
|
||||
<Style Selector="^ /template/ RepeatButton"> |
|
||||
<Style Selector="^ > Viewbox > Path"> |
|
||||
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForeground}" /> |
|
||||
</Style> |
|
||||
<Style Selector="^:pointerover > Viewbox > Path"> |
|
||||
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForegroundPointerOver}" /> |
|
||||
</Style> |
|
||||
</Style> |
|
||||
</Style> |
|
||||
</ControlTheme> |
|
||||
</ResourceDictionary> |
</ResourceDictionary> |
||||
|
|||||
Loading…
Reference in new issue