feat: extract ComboBox resources.

This commit is contained in:
Zhang Dian 2024-11-12 17:10:35 +08:00
parent d3f297730b
commit 3ce4067c3f
2 changed files with 17 additions and 17 deletions

View File

@ -30,11 +30,11 @@
<ControlTheme x:Key="{x:Type ComboBox}" TargetType="ComboBox"> <ControlTheme x:Key="{x:Type ComboBox}" TargetType="ComboBox">
<Setter Property="Padding" Value="{DynamicResource ComboBoxSelectorDefaultPadding}" /> <Setter Property="Padding" Value="{DynamicResource ComboBoxSelectorDefaultPadding}" />
<Setter Property="FocusAdorner" Value="{x:Null}" /> <Setter Property="FocusAdorner" Value="{x:Null}" />
<Setter Property="MaxDropDownHeight" Value="504" /> <Setter Property="MaxDropDownHeight" Value="{DynamicResource ComboBoxPopupMaxDropDownHeight}" />
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorBackground}" /> <Setter Property="Background" Value="{DynamicResource ComboBoxSelectorBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxSelectorBorderBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource ComboBoxSelectorBorderBrush}" />
<Setter Property="BackgroundSizing" Value="OuterBorderEdge" /> <Setter Property="BackgroundSizing" Value="OuterBorderEdge" />
<Setter Property="BorderThickness" Value="1" /> <Setter Property="BorderThickness" Value="{DynamicResource ComboBoxSelectorThickness}" />
<Setter Property="Cursor" Value="Hand" /> <Setter Property="Cursor" Value="Hand" />
<Setter Property="CornerRadius" Value="{DynamicResource ComboBoxSelectorCornerRadius}" /> <Setter Property="CornerRadius" Value="{DynamicResource ComboBoxSelectorCornerRadius}" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" /> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
@ -80,27 +80,19 @@
<Button <Button
Name="ClearButton" Name="ClearButton"
Grid.Column="1" Grid.Column="1"
Margin="0,0,8,0" Margin="{DynamicResource ComboBoxClearButtonMargin}"
Command="{Binding $parent[ComboBox].Clear}" Command="{Binding $parent[ComboBox].Clear}"
Content="{DynamicResource IconButtonClearData}" Content="{DynamicResource IconButtonClearData}"
Focusable="False" Focusable="False"
IsVisible="False" IsVisible="False"
Theme="{DynamicResource InnerIconButton}" /> Theme="{DynamicResource InnerIconButton}" />
<Border
Name="DropDownOverlay"
Grid.Column="1"
Width="30"
Margin="0,1,1,1"
HorizontalAlignment="Right"
Background="Transparent"
IsVisible="False" />
<PathIcon <PathIcon
Name="DropDownGlyph" Name="DropDownGlyph"
Grid.Column="1" Grid.Column="1"
Width="12" Width="{DynamicResource ComboBoxIconWidth}"
Height="12" Height="{DynamicResource ComboBoxIconHeight}"
Margin="0,0,12,0" Margin="{DynamicResource ComboBoxIconMargin}"
Data="{DynamicResource ComboBoxIcon}" Data="{DynamicResource ComboBoxIcon}"
Foreground="{DynamicResource ComboBoxIconDefaultForeground}" Foreground="{DynamicResource ComboBoxIconDefaultForeground}"
IsHitTestVisible="False" IsHitTestVisible="False"
@ -119,14 +111,14 @@
WindowManagerAddShadowHint="False"> WindowManagerAddShadowHint="False">
<Border <Border
Name="PopupBorder" Name="PopupBorder"
Margin="0,4"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
Margin="{DynamicResource ComboBoxPopupBorderMargin}"
Background="{DynamicResource ComboBoxPopupBackground}" Background="{DynamicResource ComboBoxPopupBackground}"
BorderBrush="{DynamicResource ComboBoxPopupBorderBrush}" BorderBrush="{DynamicResource ComboBoxPopupBorderBrush}"
BorderThickness="{DynamicResource ComboBoxPopupBorderThickness}" BorderThickness="{DynamicResource ComboBoxPopupBorderThickness}"
BoxShadow="{DynamicResource ComboBoxPopupBoxShadow}" BoxShadow="{DynamicResource ComboBoxPopupBoxShadow}"
ClipToBounds="True" CornerRadius="{DynamicResource ComboBoxPopupBoxCornerRadius}"
CornerRadius="6"> ClipToBounds="True">
<ScrollViewer <ScrollViewer
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"

View File

@ -1,14 +1,22 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<CornerRadius x:Key="ComboBoxSelectorCornerRadius">3</CornerRadius> <CornerRadius x:Key="ComboBoxSelectorCornerRadius">3</CornerRadius>
<Thickness x:Key="ComboBoxSelectorThickness">1</Thickness>
<Thickness x:Key="ComboBoxItemDefaultPadding">12 8</Thickness> <Thickness x:Key="ComboBoxItemDefaultPadding">12 8</Thickness>
<Thickness x:Key="ComboBoxSelectorDefaultPadding">8 0</Thickness> <Thickness x:Key="ComboBoxSelectorDefaultPadding">8 0</Thickness>
<x:Double x:Key="ComboBoxPopupMaxDropDownHeight">504</x:Double>
<Thickness x:Key="ComboBoxPopupBorderThickness">1</Thickness> <Thickness x:Key="ComboBoxPopupBorderThickness">1</Thickness>
<CornerRadius x:Key="ComboBoxPopupBoxCornerRadius">6</CornerRadius>
<Thickness x:Key="ComboBoxClearButtonMargin">0 0 8 0</Thickness>
<Thickness x:Key="ComboBoxIconMargin">0 0 12 0</Thickness>
<x:Double x:Key="ComboBoxIconWidth">12</x:Double>
<x:Double x:Key="ComboBoxIconHeight">12</x:Double>
<StreamGeometry x:Key="ComboBoxIcon"> <StreamGeometry x:Key="ComboBoxIcon">
M4.08045 7.59809C4.66624 7.01231 5.61599 7.01231 6.20177 7.59809L11.8586 13.2549L17.5155 7.59809C18.1013 7.01231 19.051 7.01231 19.6368 7.59809C20.2226 8.18388 20.2226 9.13363 19.6368 9.71941L12.9193 16.4369C12.3335 17.0227 11.3838 17.0227 10.798 16.4369L4.08045 9.71941C3.49467 9.13363 3.49467 8.18388 4.08045 7.59809Z M4.08045 7.59809C4.66624 7.01231 5.61599 7.01231 6.20177 7.59809L11.8586 13.2549L17.5155 7.59809C18.1013 7.01231 19.051 7.01231 19.6368 7.59809C20.2226 8.18388 20.2226 9.13363 19.6368 9.71941L12.9193 16.4369C12.3335 17.0227 11.3838 17.0227 10.798 16.4369L4.08045 9.71941C3.49467 9.13363 3.49467 8.18388 4.08045 7.59809Z
</StreamGeometry> </StreamGeometry>
<Thickness x:Key="ComboBoxPopupBorderMargin">0 4</Thickness>
<x:Double x:Key="ComboBoxDefaultHeight">32</x:Double> <x:Double x:Key="ComboBoxDefaultHeight">32</x:Double>
<x:Double x:Key="ComboBoxSmallHeight">24</x:Double> <x:Double x:Key="ComboBoxSmallHeight">24</x:Double>