45 changed files with 1684 additions and 432 deletions
@ -0,0 +1,35 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:Class="ControlCatalog.Pages.ScrollViewerPage"> |
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<TextBlock Classes="h1">ScrollViewer</TextBlock> |
|||
<TextBlock Classes="h2">Allows for horizontal and vertical content scrolling.</TextBlock> |
|||
|
|||
<Grid ColumnDefinitions="Auto, *"> |
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<ToggleSwitch IsChecked="{Binding AllowAutoHide}" Content="Allow auto hide" /> |
|||
|
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<TextBlock Text="Horizontal Scroll" /> |
|||
<ComboBox Items="{Binding AvailableVisibility}" SelectedItem="{Binding HorizontalScrollVisibility}" /> |
|||
</StackPanel> |
|||
|
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<TextBlock Text="Vertical Scroll" /> |
|||
<ComboBox Items="{Binding AvailableVisibility}" SelectedItem="{Binding VerticalScrollVisibility}" /> |
|||
</StackPanel> |
|||
</StackPanel> |
|||
|
|||
<ScrollViewer x:Name="ScrollViewer" |
|||
Grid.Column="1" |
|||
Width="400" Height="400" |
|||
AllowAutoHide="{Binding AllowAutoHide}" |
|||
HorizontalScrollBarVisibility="{Binding HorizontalScrollVisibility}" |
|||
VerticalScrollBarVisibility="{Binding VerticalScrollVisibility}"> |
|||
<Image Width="800" Height="800" Stretch="UniformToFill" |
|||
Source="/Assets/delicate-arch-896885_640.jpg" /> |
|||
</ScrollViewer> |
|||
</Grid> |
|||
|
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,65 @@ |
|||
using System.Collections.Generic; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.Primitives; |
|||
using Avalonia.Markup.Xaml; |
|||
using ReactiveUI; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public class ScrollViewerPageViewModel : ReactiveObject |
|||
{ |
|||
private bool _allowAutoHide; |
|||
private ScrollBarVisibility _horizontalScrollVisibility; |
|||
private ScrollBarVisibility _verticalScrollVisibility; |
|||
|
|||
public ScrollViewerPageViewModel() |
|||
{ |
|||
AvailableVisibility = new List<ScrollBarVisibility> |
|||
{ |
|||
ScrollBarVisibility.Auto, |
|||
ScrollBarVisibility.Visible, |
|||
ScrollBarVisibility.Hidden, |
|||
ScrollBarVisibility.Disabled, |
|||
}; |
|||
|
|||
HorizontalScrollVisibility = ScrollBarVisibility.Auto; |
|||
VerticalScrollVisibility = ScrollBarVisibility.Auto; |
|||
AllowAutoHide = true; |
|||
} |
|||
|
|||
public bool AllowAutoHide |
|||
{ |
|||
get => _allowAutoHide; |
|||
set => this.RaiseAndSetIfChanged(ref _allowAutoHide, value); |
|||
} |
|||
|
|||
public ScrollBarVisibility HorizontalScrollVisibility |
|||
{ |
|||
get => _horizontalScrollVisibility; |
|||
set => this.RaiseAndSetIfChanged(ref _horizontalScrollVisibility, value); |
|||
} |
|||
|
|||
public ScrollBarVisibility VerticalScrollVisibility |
|||
{ |
|||
get => _verticalScrollVisibility; |
|||
set => this.RaiseAndSetIfChanged(ref _verticalScrollVisibility, value); |
|||
} |
|||
|
|||
public List<ScrollBarVisibility> AvailableVisibility { get; } |
|||
} |
|||
|
|||
public class ScrollViewerPage : UserControl |
|||
{ |
|||
public ScrollViewerPage() |
|||
{ |
|||
InitializeComponent(); |
|||
|
|||
DataContext = new ScrollViewerPageViewModel(); |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
} |
|||
} |
|||
@ -1,9 +1,29 @@ |
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// Specifies a contract for a scrolling control that supports scroll anchoring.
|
|||
/// </summary>
|
|||
public interface IScrollAnchorProvider |
|||
{ |
|||
/// <summary>
|
|||
/// The currently chosen anchor element to use for scroll anchoring.
|
|||
/// </summary>
|
|||
IControl CurrentAnchor { get; } |
|||
|
|||
/// <summary>
|
|||
/// Registers a control as a potential scroll anchor candidate.
|
|||
/// </summary>
|
|||
/// <param name="element">
|
|||
/// A control within the subtree of the <see cref="IScrollAnchorProvider"/>.
|
|||
/// </param>
|
|||
void RegisterAnchorCandidate(IControl element); |
|||
|
|||
/// <summary>
|
|||
/// Unregisters a control as a potential scroll anchor candidate.
|
|||
/// </summary>
|
|||
/// <param name="element">
|
|||
/// A control within the subtree of the <see cref="IScrollAnchorProvider"/>.
|
|||
/// </param>
|
|||
void UnregisterAnchorCandidate(IControl element); |
|||
} |
|||
} |
|||
|
|||
@ -1,142 +1,302 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui"> |
|||
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
|
|||
<Style Selector="ScrollBar"> |
|||
<Setter Property="Cursor" Value="Arrow" /> |
|||
<Setter Property="MinWidth" Value="{DynamicResource ScrollBarSize}" /> |
|||
<Setter Property="MinHeight" Value="{DynamicResource ScrollBarSize}" /> |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarBackground}" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource ScrollBarForeground}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ScrollBarBorderBrush}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar:vertical"> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="{DynamicResource ThemeControlMidBrush}" |
|||
UseLayoutRounding="False"> |
|||
<Grid RowDefinitions="Auto,*,Auto"> |
|||
<RepeatButton Name="PART_LineUpButton" HorizontalAlignment="Center" |
|||
Classes="repeat" |
|||
Grid.Row="0" |
|||
Focusable="False" |
|||
MinHeight="{DynamicResource ScrollBarThickness}"> |
|||
<Path Data="M 0 4 L 8 4 L 4 0 Z" /> |
|||
</RepeatButton> |
|||
<Track Grid.Row="1" |
|||
Grid.Column="1" |
|||
Minimum="{TemplateBinding Minimum}" |
|||
Maximum="{TemplateBinding Maximum}" |
|||
Value="{TemplateBinding Value, Mode=TwoWay}" |
|||
ViewportSize="{TemplateBinding ViewportSize}" |
|||
Orientation="{TemplateBinding Orientation}" |
|||
IsDirectionReversed="True"> |
|||
<Track.DecreaseButton> |
|||
<RepeatButton Name="PART_PageUpButton" |
|||
Classes="repeattrack" |
|||
Focusable="False"/> |
|||
</Track.DecreaseButton> |
|||
<Track.IncreaseButton> |
|||
<RepeatButton Name="PART_PageDownButton" |
|||
Classes="repeattrack" |
|||
Focusable="False"/> |
|||
</Track.IncreaseButton> |
|||
<Thumb Name="thumb"/> |
|||
</Track> |
|||
<RepeatButton Name="PART_LineDownButton" HorizontalAlignment="Center" |
|||
Classes="repeat" |
|||
Grid.Row="2" |
|||
Grid.Column="2" |
|||
Focusable="False" |
|||
MinHeight="{DynamicResource ScrollBarThickness}"> |
|||
<Path Data="M 0 0 L 4 4 L 8 0 Z" /> |
|||
</RepeatButton> |
|||
</Grid> |
|||
</Border> |
|||
<Grid x:Name="Root"> |
|||
|
|||
<Border x:Name="VerticalRoot" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}"> |
|||
<Grid RowDefinitions="Auto,*,Auto"> |
|||
|
|||
<Rectangle x:Name="TrackRect" Grid.RowSpan="3" Margin="0" /> |
|||
|
|||
<RepeatButton Name="PART_LineUpButton" |
|||
HorizontalAlignment="Center" |
|||
Classes="line up" |
|||
Grid.Row="0" |
|||
Focusable="False" |
|||
MinWidth="{DynamicResource ScrollBarSize}" |
|||
Height="{DynamicResource ScrollBarSize}" /> |
|||
|
|||
<Track Grid.Row="1" |
|||
Minimum="{TemplateBinding Minimum}" |
|||
Maximum="{TemplateBinding Maximum}" |
|||
Value="{TemplateBinding Value, Mode=TwoWay}" |
|||
ViewportSize="{TemplateBinding ViewportSize}" |
|||
Orientation="{TemplateBinding Orientation}" |
|||
IsDirectionReversed="True"> |
|||
<Track.DecreaseButton> |
|||
<RepeatButton Name="PART_PageUpButton" |
|||
Classes="largeIncrease" |
|||
Focusable="False" /> |
|||
</Track.DecreaseButton> |
|||
<Track.IncreaseButton> |
|||
<RepeatButton Name="PART_PageDownButton" |
|||
Classes="largeIncrease" |
|||
Focusable="False" /> |
|||
</Track.IncreaseButton> |
|||
<Thumb Classes="thumb" |
|||
Opacity="1" |
|||
Width="{DynamicResource ScrollBarSize}" |
|||
MinHeight="{DynamicResource ScrollBarSize}" |
|||
RenderTransformOrigin="100%,50%" /> |
|||
</Track> |
|||
|
|||
<RepeatButton Name="PART_LineDownButton" |
|||
HorizontalAlignment="Center" |
|||
Classes="line down" |
|||
Grid.Row="2" |
|||
Focusable="False" |
|||
MinWidth="{DynamicResource ScrollBarSize}" |
|||
Height="{DynamicResource ScrollBarSize}" /> |
|||
|
|||
</Grid> |
|||
</Border> |
|||
|
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar:horizontal"> |
|||
<Setter Property="Height" Value="{DynamicResource ScrollBarThickness}" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="{DynamicResource ThemeControlMidBrush}" |
|||
UseLayoutRounding="False"> |
|||
<Grid ColumnDefinitions="Auto,*,Auto"> |
|||
<RepeatButton Name="PART_LineUpButton" VerticalAlignment="Center" |
|||
Classes="repeat" |
|||
Grid.Row="0" |
|||
Grid.Column="0" |
|||
Focusable="False" |
|||
MinWidth="{DynamicResource ScrollBarThickness}"> |
|||
<Path Data="M 4 0 L 4 8 L 0 4 Z" /> |
|||
</RepeatButton> |
|||
<Track Grid.Row="1" |
|||
Grid.Column="1" |
|||
Minimum="{TemplateBinding Minimum}" |
|||
Maximum="{TemplateBinding Maximum}" |
|||
Value="{TemplateBinding Value, Mode=TwoWay}" |
|||
ViewportSize="{TemplateBinding ViewportSize}" |
|||
Orientation="{TemplateBinding Orientation}"> |
|||
<Track.DecreaseButton> |
|||
<RepeatButton Name="PART_PageUpButton" |
|||
Classes="repeattrack" |
|||
Focusable="False"/> |
|||
</Track.DecreaseButton> |
|||
<Track.IncreaseButton> |
|||
<RepeatButton Name="PART_PageDownButton" |
|||
Classes="repeattrack" |
|||
Focusable="False"/> |
|||
</Track.IncreaseButton> |
|||
<Thumb Name="thumb"/> |
|||
</Track> |
|||
<RepeatButton Name="PART_LineDownButton" VerticalAlignment="Center" |
|||
Classes="repeat" |
|||
Grid.Row="2" |
|||
Grid.Column="2" |
|||
Focusable="False" |
|||
MinWidth="{DynamicResource ScrollBarThickness}"> |
|||
<Path Data="M 0 0 L 4 4 L 0 8 Z" /> |
|||
</RepeatButton> |
|||
</Grid> |
|||
</Border> |
|||
<Grid x:Name="Root"> |
|||
|
|||
<Border x:Name="HorizontalRoot" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}"> |
|||
<Grid ColumnDefinitions="Auto,*,Auto"> |
|||
|
|||
<Rectangle x:Name="TrackRect" Grid.ColumnSpan="3" Margin="0" /> |
|||
|
|||
<RepeatButton Name="PART_LineUpButton" |
|||
VerticalAlignment="Center" |
|||
Classes="line up" |
|||
Grid.Column="0" |
|||
Focusable="False" |
|||
MinHeight="{DynamicResource ScrollBarSize}" |
|||
Width="{DynamicResource ScrollBarSize}" /> |
|||
|
|||
<Track Grid.Column="1" |
|||
Minimum="{TemplateBinding Minimum}" |
|||
Maximum="{TemplateBinding Maximum}" |
|||
Value="{TemplateBinding Value, Mode=TwoWay}" |
|||
ViewportSize="{TemplateBinding ViewportSize}" |
|||
Orientation="{TemplateBinding Orientation}"> |
|||
<Track.DecreaseButton> |
|||
<RepeatButton Name="PART_PageUpButton" |
|||
Classes="largeIncrease" |
|||
Focusable="False" /> |
|||
</Track.DecreaseButton> |
|||
<Track.IncreaseButton> |
|||
<RepeatButton Name="PART_PageDownButton" |
|||
Classes="largeIncrease" |
|||
Focusable="False" /> |
|||
</Track.IncreaseButton> |
|||
<Thumb Classes="thumb" |
|||
Opacity="1" |
|||
Height="{DynamicResource ScrollBarSize}" |
|||
MinWidth="{DynamicResource ScrollBarSize}" |
|||
RenderTransformOrigin="50%,100%" /> |
|||
</Track> |
|||
|
|||
<RepeatButton Name="PART_LineDownButton" |
|||
VerticalAlignment="Center" |
|||
Classes="line down" |
|||
Grid.Column="2" |
|||
Focusable="False" |
|||
MinHeight="{DynamicResource ScrollBarSize}" |
|||
Width="{DynamicResource ScrollBarSize}" /> |
|||
|
|||
</Grid> |
|||
</Border> |
|||
|
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="ScrollBar /template/ Thumb#thumb"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlMidHighBrush}"/> |
|||
|
|||
<Style Selector="ScrollBar[IsExpanded=true] /template/ Grid#Root"> |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarBackgroundPointerOver}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ Thumb.thumb"> |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarPanningThumbBackground}" /> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate> |
|||
<Border Background="{TemplateBinding Background}"/> |
|||
<Border x:Name="ThumbVisual" Background="{TemplateBinding Background}" /> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
<Setter Property="Transitions"> |
|||
<Transitions> |
|||
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.1" /> |
|||
</Transitions> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="ScrollBar /template/ Thumb#thumb:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlHighBrush}"/> |
|||
|
|||
<Style Selector="ScrollBar:vertical /template/ Thumb.thumb"> |
|||
<Setter Property="RenderTransform" Value="{DynamicResource VerticalSmallScrollThumbScaleTransform}" /> |
|||
</Style> |
|||
<Style Selector="ScrollBar /template/ Thumb#thumb:pressed"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlVeryHighBrush}"/> |
|||
|
|||
<Style Selector="ScrollBar:horizontal /template/ Thumb.thumb"> |
|||
<Setter Property="RenderTransform" Value="{DynamicResource HorizontalSmallScrollThumbScaleTransform}" /> |
|||
</Style> |
|||
<Style Selector="ScrollBar:horizontal /template/ Thumb#thumb"> |
|||
<Setter Property="MinWidth" Value="{DynamicResource ScrollBarThickness}" /> |
|||
<Setter Property="Height" Value="{DynamicResource ScrollBarThumbThickness}" /> |
|||
|
|||
<Style Selector="ScrollBar[IsExpanded=true] /template/ Thumb.thumb"> |
|||
<Setter Property="RenderTransform" Value="none" /> |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbBackgroundColor}" /> |
|||
</Style> |
|||
<Style Selector="ScrollBar:vertical"> |
|||
<Setter Property="Width" Value="{DynamicResource ScrollBarThickness}" /> |
|||
|
|||
<Style Selector="ScrollBar /template/ Thumb.thumb /template/ Border#ThumbVisual"> |
|||
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> |
|||
<Setter Property="Transitions"> |
|||
<Transitions> |
|||
<CornerRadiusTransition Property="CornerRadius" Duration="0:0:0.1" /> |
|||
</Transitions> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="ScrollBar:vertical /template/ Thumb#thumb"> |
|||
<Setter Property="MinHeight" Value="{DynamicResource ScrollBarThickness}" /> |
|||
<Setter Property="Width" Value="{DynamicResource ScrollBarThumbThickness}" /> |
|||
|
|||
<Style Selector="ScrollBar[IsExpanded=true] /template/ Thumb.thumb /template/ Border#ThumbVisual"> |
|||
<Setter Property="CornerRadius" Value="0" /> |
|||
</Style> |
|||
<Style Selector="ScrollBar /template/ RepeatButton.repeat"> |
|||
<Setter Property="Padding" Value="2" /> |
|||
<Setter Property="BorderThickness" Value="0" /> |
|||
|
|||
<Style Selector="ScrollBar /template/ Thumb.thumb:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbFillPointerOver}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ Thumb.thumb:pressed"> |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbFillPressed}" /> |
|||
</Style> |
|||
<Style Selector="ScrollBar /template/ RepeatButton.repeattrack"> |
|||
|
|||
<Style Selector="ScrollBar /template/ Thumb.thumb:disabled"> |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbFillDisabled}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line"> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="{TemplateBinding Background}" /> |
|||
<Border x:Name="Root"> |
|||
<Viewbox Width="{DynamicResource ScrollBarButtonArrowIconFontSize}" |
|||
Height="{DynamicResource ScrollBarButtonArrowIconFontSize}"> |
|||
<Path x:Name="Arrow" |
|||
VerticalAlignment="Center" |
|||
HorizontalAlignment="Center" |
|||
Width="20" Height="20" /> |
|||
</Viewbox> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
<Setter Property="Transitions"> |
|||
<Transitions> |
|||
<DoubleTransition Property="Opacity" Duration="0:0:0.1" /> |
|||
</Transitions> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line /template/ Border#Root" > |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarButtonBackground}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ScrollBarButtonBorderBrush}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line:pointerover /template/ Border#Root" > |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarButtonBackgroundPointerOver}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ScrollBarButtonBorderBrushPointerOver}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line:pressed /template/ Border#Root" > |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarButtonBackgroundPressed}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ScrollBarButtonBorderBrushPressed}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line:disabled /template/ Border#Root" > |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarButtonBackgroundPressed}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ScrollBarButtonBorderBrushDisabled}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line /template/ Path#Arrow" > |
|||
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForeground}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line:pointerover /template/ Path#Arrow" > |
|||
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForegroundPointerOver}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line:pressed /template/ Path#Arrow" > |
|||
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForegroundPressed}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line:disabled /template/ Path#Arrow" > |
|||
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForegroundDisabled}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar[IsExpanded=true] /template/ RepeatButton.line"> |
|||
<Setter Property="Opacity" Value="1" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton > Path"> |
|||
<Setter Property="Fill" Value="{DynamicResource ThemeForegroundLowBrush}" /> |
|||
<Style Selector="ScrollBar:vertical /template/ RepeatButton.line.up /template/ Path"> |
|||
<Setter Property="Data" |
|||
Value="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" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton:pointerover > Path"> |
|||
<Setter Property="Fill" Value="{DynamicResource ThemeAccentBrush}" /> |
|||
<Style Selector="ScrollBar:vertical /template/ RepeatButton.line.down /template/ Path"> |
|||
<Setter Property="Data" |
|||
Value="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" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar:horizontal /template/ RepeatButton.line.up /template/ Path"> |
|||
<Setter Property="Data" Value="M 14.091797 19.970703 L 4.111328 10 L 14.091797 0.029297 L 14.970703 0.908203 L 5.888672 10 L 14.970703 19.091797 Z" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar:horizontal /template/ RepeatButton.line.down /template/ Path"> |
|||
<Setter Property="Data" Value="M 5.029297 19.091797 L 14.111328 10 L 5.029297 0.908203 L 5.908203 0.029297 L 15.888672 10 L 5.908203 19.970703 Z" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ Rectangle#TrackRect"> |
|||
<Setter Property="StrokeThickness" Value="{DynamicResource ScrollBarTrackBorderThemeThickness}" /> |
|||
<Setter Property="Fill" Value="{DynamicResource ScrollBarTrackFill}" /> |
|||
<Setter Property="Stroke" Value="{DynamicResource ScrollBarTrackStroke}" /> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
<Setter Property="Transitions"> |
|||
<Transitions> |
|||
<DoubleTransition Property="Opacity" Duration="0:0:0.1" /> |
|||
</Transitions> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar[IsExpanded=true] /template/ Rectangle#TrackRect"> |
|||
<Setter Property="Fill" Value="{DynamicResource ScrollBarTrackFillPointerOver}" /> |
|||
<Setter Property="Stroke" Value="{DynamicResource ScrollBarTrackStrokePointerOver}" /> |
|||
<Setter Property="Opacity" Value="1" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.largeIncrease"> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="{TemplateBinding Background}" /> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
<Setter Property="Background" Value="Transparent" /> |
|||
<Setter Property="VerticalAlignment" Value="Stretch" /> |
|||
<Setter Property="HorizontalAlignment" Value="Stretch" /> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar[IsExpanded=true] /template/ RepeatButton.largeIncrease"> |
|||
<Setter Property="Opacity" Value="1" /> |
|||
</Style> |
|||
|
|||
</Styles> |
|||
|
|||
@ -1,47 +1,69 @@ |
|||
<Style xmlns="https://github.com/avaloniaui" Selector="ScrollViewer"> |
|||
<Setter Property="Background" |
|||
Value="Transparent" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Grid ColumnDefinitions="*,Auto" RowDefinitions="*,Auto"> |
|||
<ScrollContentPresenter Name="PART_ContentPresenter" |
|||
Background="{TemplateBinding Background}" |
|||
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> |
|||
<ScrollBar Name="horizontalScrollBar" |
|||
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="verticalScrollBar" |
|||
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 Grid.Row="1" Grid.Column="1" Background="{DynamicResource ThemeControlMidBrush}"/> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
|
|||
<Style Selector="ScrollViewer"> |
|||
<Setter Property="Background" |
|||
Value="Transparent" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Grid ColumnDefinitions="*,Auto" RowDefinitions="*,Auto"> |
|||
<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}" |
|||
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> |
|||
<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> |
|||
|
|||
<Style Selector="ScrollViewer /template/ Panel#PART_ScrollBarsSeparator"> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
<Setter Property="Transitions"> |
|||
<Transitions> |
|||
<DoubleTransition Property="Opacity" Duration="0:0:0.1" /> |
|||
</Transitions> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollViewer[IsExpanded=true] /template/ Panel#PART_ScrollBarsSeparator"> |
|||
<Setter Property="Opacity" Value="1" /> |
|||
</Style> |
|||
|
|||
</Styles> |
|||
|
|||
@ -1,92 +1,180 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls"> |
|||
<Style Selector="TreeViewItem"> |
|||
<Style.Resources> |
|||
<converters:MarginMultiplierConverter Indent="16" Left="True" x:Key="LeftMarginConverter" /> |
|||
</Style.Resources> |
|||
<Setter Property="Padding" Value="2"/> |
|||
<Setter Property="Background" Value="Transparent"/> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<StackPanel> |
|||
<Border Name="SelectionBorder" |
|||
Focusable="True" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
TemplatedControl.IsTemplateFocusTarget="True"> |
|||
<Grid Name="PART_Header" |
|||
ColumnDefinitions="16, *" |
|||
Margin="{TemplateBinding Level, Mode=OneWay, Converter={StaticResource LeftMarginConverter}}" > |
|||
<ToggleButton Name="expander" |
|||
Focusable="False" |
|||
IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}"/> |
|||
<ContentPresenter Name="PART_HeaderPresenter" |
|||
Focusable="False" |
|||
Content="{TemplateBinding Header}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalAlignment}" |
|||
Padding="{TemplateBinding Padding}" |
|||
Grid.Column="1"/> |
|||
</Grid> |
|||
</Border> |
|||
<ItemsPresenter Name="PART_ItemsPresenter" |
|||
IsVisible="{TemplateBinding IsExpanded}" |
|||
Items="{TemplateBinding Items}" |
|||
ItemsPanel="{TemplateBinding ItemsPanel}"/> |
|||
</StackPanel> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="TreeViewItem /template/ ToggleButton#expander"> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="Transparent" |
|||
Width="14" |
|||
Height="12" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center"> |
|||
<Path Fill="{DynamicResource ThemeForegroundBrush}" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center" |
|||
Data="M 0 2 L 4 6 L 0 10 Z"/> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Design.PreviewWith> |
|||
<Border Padding="20" |
|||
MinWidth="300"> |
|||
<TreeView> |
|||
<TreeViewItem Header="Level 1"> |
|||
<TreeViewItem Header="Level 2.1"> |
|||
<TreeViewItem Header="Level 3.1" /> |
|||
<TreeViewItem Header="Level 3.2"> |
|||
<TreeViewItem Header="Level 4" /> |
|||
</TreeViewItem> |
|||
</TreeViewItem> |
|||
<TreeViewItem Header="Level 2.2" |
|||
IsEnabled="False" /> |
|||
</TreeViewItem> |
|||
</TreeView> |
|||
</Border> |
|||
</Design.PreviewWith> |
|||
|
|||
<Style Selector="TreeViewItem /template/ ContentPresenter#PART_HeaderPresenter"> |
|||
<Setter Property="Padding" Value="2"/> |
|||
</Style> |
|||
<Styles.Resources> |
|||
<x:Double x:Key="TreeViewItemIndent">16</x:Double> |
|||
<x:Double x:Key="TreeViewItemExpandCollapseChevronSize">12</x:Double> |
|||
<Thickness x:Key="TreeViewItemExpandCollapseChevronMargin">12, 0, 12, 0</Thickness> |
|||
<StreamGeometry x:Key="TreeViewItemCollapsedChevronPathData">M 1,0 10,10 l -9,10 -1,-1 L 8,10 -0,1 Z</StreamGeometry> |
|||
<StreamGeometry x:Key="TreeViewItemExpandedChevronPathData">M0,1 L10,10 20,1 19,0 10,8 1,0 Z</StreamGeometry> |
|||
<converters:MarginMultiplierConverter Indent="{StaticResource TreeViewItemIndent}" |
|||
Left="True" |
|||
x:Key="TreeViewItemLeftMarginConverter" /> |
|||
</Styles.Resources> |
|||
|
|||
<Style Selector="TreeViewItem /template/ Border#SelectionBorder:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlHighlightMidBrush}"/> |
|||
</Style> |
|||
<Style Selector="ToggleButton.ExpandCollapseChevron"> |
|||
<Setter Property="Margin" Value="0" /> |
|||
<Setter Property="Width" Value="{StaticResource TreeViewItemExpandCollapseChevronSize}" /> |
|||
<Setter Property="Height" Value="{StaticResource TreeViewItemExpandCollapseChevronSize}" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="Transparent" |
|||
Width="{TemplateBinding Width}" |
|||
Height="{TemplateBinding Height}" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center"> |
|||
<Path x:Name="ChevronPath" |
|||
Fill="{DynamicResource TreeViewItemForeground}" |
|||
Stretch="Uniform" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center" /> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="TreeViewItem:selected /template/ Border#SelectionBorder"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush4}"/> |
|||
</Style> |
|||
<Style Selector="TreeViewItem"> |
|||
<Style.Resources /> |
|||
<Setter Property="Padding" Value="0" /> |
|||
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackground}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TreeViewItemBorderBrush}" /> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource TreeViewItemBorderThemeThickness}" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource TreeViewItemForeground}" /> |
|||
<Setter Property="MinHeight" Value="{DynamicResource TreeViewItemMinHeight}" /> |
|||
<Setter Property="VerticalAlignment" Value="Center" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<StackPanel> |
|||
<Border Name="PART_LayoutRoot" |
|||
Classes="TreeViewItemLayoutRoot" |
|||
Focusable="True" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
MinHeight="{TemplateBinding MinHeight}" |
|||
TemplatedControl.IsTemplateFocusTarget="True"> |
|||
<Grid Name="PART_Header" |
|||
ColumnDefinitions="Auto, *" |
|||
Margin="{TemplateBinding Level, Mode=OneWay, Converter={StaticResource TreeViewItemLeftMarginConverter}}"> |
|||
<Panel Name="PART_ExpandCollapseChevronContainer" |
|||
Margin="{StaticResource TreeViewItemExpandCollapseChevronMargin}"> |
|||
<ToggleButton Name="PART_ExpandCollapseChevron" |
|||
Classes="ExpandCollapseChevron" |
|||
Focusable="False" |
|||
IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}" /> |
|||
</Panel> |
|||
<ContentPresenter Name="PART_HeaderPresenter" |
|||
Grid.Column="1" |
|||
Focusable="False" |
|||
Content="{TemplateBinding Header}" |
|||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}" |
|||
VerticalAlignment="{TemplateBinding VerticalAlignment}" |
|||
Margin="{TemplateBinding Padding}" /> |
|||
</Grid> |
|||
</Border> |
|||
<ItemsPresenter Name="PART_ItemsPresenter" |
|||
IsVisible="{TemplateBinding IsExpanded}" |
|||
Items="{TemplateBinding Items}" |
|||
ItemsPanel="{TemplateBinding ItemsPanel}" /> |
|||
</StackPanel> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="TreeViewItem:selected /template/ Border#SelectionBorder:focus"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush3}"/> |
|||
</Style> |
|||
<!-- PointerOver state --> |
|||
<Style Selector="TreeViewItem /template/ Border#PART_LayoutRoot:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackgroundPointerOver}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TreeViewItemBorderBrushPointerOver}" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem /template/ Border#PART_LayoutRoot:pointerover > ContentPresenter#PART_HeaderPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TreeViewItemForegroundPointerOver}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="TreeViewItem:selected /template/ Border#SelectionBorder:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush3}"/> |
|||
</Style> |
|||
<!-- Pressed state --> |
|||
<Style Selector="TreeViewItem:pressed /template/ Border#PART_LayoutRoot:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackgroundPressed}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TreeViewItemBorderBrushPressed}" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem:pressed /template/ Border#PART_LayoutRoot:pointerover > ContentPresenter#PART_HeaderPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TreeViewItemForegroundPressed}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="TreeViewItem:selected /template/ Border#SelectionBorder:pointerover:focus"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush2}"/> |
|||
</Style> |
|||
<!-- Disabled state --> |
|||
<Style Selector="TreeViewItem:disabled /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackgroundDisabled}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TreeViewItemBorderBrushDisabled}" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem:disabled /template/ Border#PART_LayoutRoot > ContentPresenter#PART_HeaderPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TreeViewItemForegroundDisabled}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="TreeViewItem /template/ ToggleButton#expander:checked"> |
|||
<Setter Property="RenderTransform"> |
|||
<RotateTransform Angle="45"/> |
|||
</Setter> |
|||
</Style> |
|||
<!-- Selected state --> |
|||
<Style Selector="TreeViewItem:selected /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackgroundSelected}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TreeViewItemBorderBrushSelected}" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem:selected /template/ Border#PART_LayoutRoot > ContentPresenter#PART_HeaderPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TreeViewItemForegroundSelected}" /> |
|||
</Style> |
|||
|
|||
<!-- Selected PointerOver state --> |
|||
<Style Selector="TreeViewItem:selected /template/ Border#PART_LayoutRoot:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackgroundSelectedPointerOver}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TreeViewItemBorderBrushSelectedPointerOver}" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem:selected /template/ Border#PART_LayoutRoot:pointerover > ContentPresenter#PART_HeaderPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TreeViewItemForegroundSelectedPointerOver}" /> |
|||
</Style> |
|||
|
|||
<!-- Selected Pressed state --> |
|||
<Style Selector="TreeViewItem:pressed:selected /template/ Border#PART_LayoutRoot:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackgroundSelectedPressed}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TreeViewItemBorderBrushSelectedPressed}" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem:pressed:selected /template/ Border#PART_LayoutRoot:pointerover > ContentPresenter#PART_HeaderPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TreeViewItemForegroundSelectedPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- Disabled Selected state --> |
|||
<Style Selector="TreeViewItem:disabled:selected /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackgroundSelectedDisabled}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TreeViewItemBorderBrushSelectedDisabled}" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem:disabled:selected /template/ Border#PART_LayoutRoot > ContentPresenter#PART_HeaderPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TreeViewItemForegroundSelectedDisabled}" /> |
|||
</Style> |
|||
|
|||
<!-- ExpandCollapseChevron Group states --> |
|||
<Style Selector="ToggleButton.ExpandCollapseChevron /template/ Path#ChevronPath"> |
|||
<Setter Property="Data" Value="{StaticResource TreeViewItemCollapsedChevronPathData}" /> |
|||
</Style> |
|||
<Style Selector="ToggleButton.ExpandCollapseChevron:checked /template/ Path#ChevronPath"> |
|||
<Setter Property="Data" Value="{StaticResource TreeViewItemExpandedChevronPathData}" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem:empty /template/ ToggleButton#PART_ExpandCollapseChevron"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem:empty /template/ Panel#PART_ExpandCollapseChevronContainer"> |
|||
<Setter Property="Width" Value="{StaticResource TreeViewItemExpandCollapseChevronSize}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="TreeViewItem:empty /template/ ToggleButton#expander"> |
|||
<Setter Property="IsVisible" Value="False"/> |
|||
</Style> |
|||
</Styles> |
|||
|
|||
@ -0,0 +1,27 @@ |
|||
using System; |
|||
using Xunit; |
|||
|
|||
namespace Avalonia.Layout.UnitTests |
|||
{ |
|||
public class LayoutHelperTests |
|||
{ |
|||
[Fact] |
|||
public void Round_Layout_Value_Without_DPI_Aware() |
|||
{ |
|||
const double value = 42.5; |
|||
var expectedValue = Math.Round(value); |
|||
var actualValue = LayoutHelper.RoundLayoutValue(value, 1.0); |
|||
Assert.Equal(expectedValue, actualValue); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Round_Layout_Value_With_DPI_Aware() |
|||
{ |
|||
const double dpiScale = 1.25; |
|||
const double value = 42.5; |
|||
var expectedValue = Math.Round(value * dpiScale) / dpiScale; |
|||
var actualValue = LayoutHelper.RoundLayoutValue(value, dpiScale); |
|||
Assert.Equal(expectedValue, actualValue); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue