feat: extract ComboBox resources.

(cherry picked from commit 3ce4067c3f2e7165c63391f240e38e906412c237)
This commit is contained in:
Zhang Dian 2024-11-12 17:10:35 +08:00
parent ffbfe959f9
commit 590d14117d
2 changed files with 17 additions and 17 deletions

View File

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