A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

93 lines
4.4 KiB

<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}"
CornerRadius="{TemplateBinding CornerRadius}"
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>
<Style Selector="TreeViewItem /template/ ContentPresenter#PART_HeaderPresenter">
<Setter Property="Padding" Value="2"/>
</Style>
<Style Selector="TreeViewItem /template/ Border#SelectionBorder:pointerover">
<Setter Property="Background" Value="{DynamicResource ThemeControlHighlightMidBrush}"/>
</Style>
<Style Selector="TreeViewItem:selected /template/ Border#SelectionBorder">
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush4}"/>
</Style>
<Style Selector="TreeViewItem:selected /template/ Border#SelectionBorder:focus">
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush3}"/>
</Style>
<Style Selector="TreeViewItem:selected /template/ Border#SelectionBorder:pointerover">
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush3}"/>
</Style>
<Style Selector="TreeViewItem:selected /template/ Border#SelectionBorder:pointerover:focus">
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush2}"/>
</Style>
<Style Selector="TreeViewItem /template/ ToggleButton#expander:checked">
<Setter Property="RenderTransform">
<RotateTransform Angle="45"/>
</Setter>
</Style>
<Style Selector="TreeViewItem:empty /template/ ToggleButton#expander">
<Setter Property="IsVisible" Value="False"/>
</Style>
</Styles>