Files
Ursa.Avalonia/src/Ursa.Themes.Semi/Controls/TreeComboBox.axaml

186 lines
10 KiB
XML

<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa"
xmlns:iri="https://irihi.tech/shared"
xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls"
xmlns:converters1="clr-namespace:Ursa.Themes.Semi.Converters">
<!-- Add Resources Here -->
<converters:MarginMultiplierConverter x:Key="LeftMarginConverter" Indent="20" Left="True"/>
<converters1:SelectedItemTemplateConverter x:Key="SelectedItemTemplateConverter"/>
<ControlTheme x:Key="{x:Type u:TreeComboBox}" TargetType="u:TreeComboBox">
<Setter Property="Padding" Value="{DynamicResource ComboBoxSelectorDefaultPadding}"/>
<Setter Property="FocusAdorner" Value="{x:Null}"/>
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorBackground}"/>
<Setter Property="CornerRadius" Value="{DynamicResource ComboBoxSelectorCornerRadius}"/>
<Setter Property="VerticalContentAlignment" Value="Center"></Setter>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<ControlTemplate TargetType="u:TreeComboBox">
<Grid ColumnDefinitions="*, Auto, Auto">
<Border Grid.Column="0"
Name="Background"
Grid.ColumnSpan="3"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
MinHeight="32"
/>
<TextBlock
Name="PlaceholderTextBlock"
Grid.Column="0"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
TextTrimming="CharacterEllipsis"
Foreground="{TemplateBinding Foreground}"
Opacity="0.3"
IsVisible="{TemplateBinding SelectionBoxItem, Converter={x:Static ObjectConverters.IsNull}}"
Text="{TemplateBinding Watermark}"
></TextBlock>
<ContentPresenter
Grid.Column="0"
Margin="{TemplateBinding Padding}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
VerticalAlignment="Center"
Content="{TemplateBinding SelectionBoxItem}">
<ContentPresenter.ContentTemplate>
<MultiBinding Converter="{x:Static converters1:SelectedItemTemplateConverter.Instance}">
<TemplateBinding Property="SelectedItemTemplate"/>
<TemplateBinding Property="ItemTemplate"/>
</MultiBinding>
</ContentPresenter.ContentTemplate>
</ContentPresenter>
<Border
x:Name="DropDownOverlay"
Grid.Column="2"
Width="30"
Margin="0,1,1,1"
HorizontalAlignment="Right"
Background="Transparent"
IsVisible="False" />
<Panel Grid.Column="2" Width="32" IsHitTestVisible="False">
<PathIcon
x:Name="DropDownGlyph"
Width="12"
Height="12"
Margin="0,0,10,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Data="{DynamicResource ComboBoxIcon}"
Foreground="{DynamicResource ComboBoxIconDefaultForeground}"
UseLayoutRounding="False" />
</Panel>
<Popup
Name="{x:Static iri:PartNames.PART_Popup}"
Grid.Column="0"
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
MinHeight="{TemplateBinding MaxDropDownHeight}"
ClipToBounds="False"
InheritsTransform="True"
PlacementTarget="Background"
WindowManagerAddShadowHint="False"
IsLightDismissEnabled="True"
IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}">
<Border
Name="PopupBorder"
Margin="0 4"
Background="{DynamicResource ComboBoxPopupBackground}"
BorderBrush="{DynamicResource ComboBoxPopupBorderBrush}"
BoxShadow="{DynamicResource ComboBoxPopupBoxShadow}"
ClipToBounds="True"
CornerRadius="6"
>
<ScrollViewer>
<ItemsPresenter ItemsPanel="{TemplateBinding ItemsPanel}"/>
</ScrollViewer>
</Border>
</Popup>
</Grid>
</ControlTemplate>
</Setter>
</ControlTheme>
<ControlTheme x:Key="{x:Type u:TreeComboBoxItem}" TargetType="u:TreeComboBoxItem">
<Setter Property="Background" Value="{DynamicResource TreeViewItemDefaultBackground}"/>
<Setter Property="Foreground" Value="{DynamicResource TreeViewItemDefaultForeground}"/>
<Setter Property="CornerRadius" Value="3"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Template">
<ControlTemplate TargetType="u:TreeComboBoxItem">
<StackPanel>
<Border
Name="PART_LayoutRoot"
MinHeight="{TemplateBinding MinHeight}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
TemplatedControl.IsTemplateFocusTarget="True">
<Grid
Name="{x:Static iri:PartNames.PART_Header}"
Margin="{TemplateBinding Level, Mode=OneWay, Converter={StaticResource LeftMarginConverter}}"
ColumnDefinitions="Auto, *">
<ToggleButton
IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}"
Theme="{DynamicResource ToggleButtonTreeViewItemIconButton}"
Name="PART_ExpandCollapseChevron"
Grid.Column="0"
Padding="{DynamicResource TreeViewItemIconMargin}"
Focusable="False"></ToggleButton>
<ContentPresenter
Grid.Column="1"
Name="{x:Static iri:PartNames.PART_HeaderPresenter}"
Margin="{TemplateBinding Padding}"
Padding="{DynamicResource TreeViewItemPadding}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
Foreground="{TemplateBinding Foreground}"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
Focusable="False"/>
</Grid>
</Border>
<ItemsPresenter IsVisible="{TemplateBinding IsExpanded}" Name="{x:Static iri:PartNames.PART_ItemsPresenter}" ItemsPanel="{TemplateBinding ItemsPanel}"/>
</StackPanel>
</ControlTemplate>
</Setter>
<!-- Pointerover state -->
<Style Selector="^ /template/ Border#PART_LayoutRoot:pointerover">
<Setter Property="Background" Value="{DynamicResource TreeViewItemPointeroverBackground}" />
</Style>
<!-- Pressed state -->
<Style Selector="^:pressed /template/ Border#PART_LayoutRoot:pointerover">
<Setter Property="Background" Value="{DynamicResource TreeViewItemPressedBackground}" />
</Style>
<!-- Disabled state -->
<Style Selector="^:disabled /template/ Border#PART_LayoutRoot">
<Setter Property="Background" Value="{DynamicResource TreeViewItemDisabledBackground}" />
</Style>
<Style Selector="^:disabled /template/ ContentPresenter#PART_HeaderPresenter">
<Setter Property="Foreground" Value="{DynamicResource TreeViewItemDisabledForeground}" />
</Style>
<!-- Selected state -->
<Style Selector="^:selected /template/ Border#PART_LayoutRoot">
<Setter Property="Background" Value="{DynamicResource TreeViewItemSelectedBackground}" />
</Style>
<!-- Disabled Selected state -->
<Style Selector="^:disabled:selected /template/ Border#PART_LayoutRoot">
<Setter Property="Background" Value="{DynamicResource TreeViewItemSelectedDisabledBackground}" />
</Style>
<Style Selector="^:empty /template/ ToggleButton#PART_ExpandCollapseChevron">
<Setter Property="Opacity" Value="0" />
<Setter Property="IsHitTestVisible" Value="False" />
</Style>
</ControlTheme>
</ResourceDictionary>