|
1 | 1 | <ResourceDictionary xmlns="https://github.com/avaloniaui"
|
2 |
| - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
3 |
| - <ControlTheme x:Key="{x:Type ListBox}" |
| 2 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 3 | + xmlns:hc="clr-namespace:HandyControl.Controls"> |
| 4 | + <ControlTheme x:Key="ListBoxItemBaseStyle" |
| 5 | + TargetType="ListBoxItem"> |
| 6 | + <Setter Property="Padding" |
| 7 | + Value="10,0" /> |
| 8 | + <Setter Property="MinHeight" |
| 9 | + Value="{StaticResource DefaultControlHeight}" /> |
| 10 | + <Setter Property="VerticalContentAlignment" |
| 11 | + Value="Center" /> |
| 12 | + <Setter Property="Background" |
| 13 | + Value="{DynamicResource RegionBrush}" /> |
| 14 | + <Setter Property="BorderBrush" |
| 15 | + Value="Transparent" /> |
| 16 | + <Setter Property="CornerRadius" |
| 17 | + Value="{Binding $self.(hc:BorderElement.CornerRadius)}" /> |
| 18 | + <Setter Property="BorderThickness" |
| 19 | + Value="0" /> |
| 20 | + <Setter Property="Margin" |
| 21 | + Value="0,0,0,2" /> |
| 22 | + <Setter Property="Template"> |
| 23 | + <ControlTemplate> |
| 24 | + <ContentPresenter Name="PART_ContentPresenter" |
| 25 | + Padding="{TemplateBinding Padding}" |
| 26 | + HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
| 27 | + VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
| 28 | + Background="{TemplateBinding Background}" |
| 29 | + BorderBrush="{TemplateBinding BorderBrush}" |
| 30 | + BorderThickness="{TemplateBinding BorderThickness}" |
| 31 | + Content="{TemplateBinding Content}" |
| 32 | + ContentTemplate="{TemplateBinding ContentTemplate}" |
| 33 | + CornerRadius="{TemplateBinding CornerRadius}" /> |
| 34 | + </ControlTemplate> |
| 35 | + </Setter> |
| 36 | + |
| 37 | + <Style Selector="^:pointerover /template/ ContentPresenter"> |
| 38 | + <Setter Property="Background" |
| 39 | + Value="{DynamicResource SecondaryRegionBrush}" /> |
| 40 | + </Style> |
| 41 | + |
| 42 | + <Style Selector="^:selected /template/ ContentPresenter"> |
| 43 | + <Setter Property="Background" |
| 44 | + Value="{DynamicResource PrimaryBrush}" /> |
| 45 | + <Setter Property="Foreground" |
| 46 | + Value="{DynamicResource TextIconBrush}" /> |
| 47 | + </Style> |
| 48 | + |
| 49 | + <Style Selector="^:disabled"> |
| 50 | + <Setter Property="Opacity" |
| 51 | + Value="0.4" /> |
| 52 | + </Style> |
| 53 | + </ControlTheme> |
| 54 | + |
| 55 | + <ControlTheme x:Key="ListBoxBaseStyle" |
4 | 56 | TargetType="ListBox">
|
5 | 57 | <Setter Property="Background"
|
6 | 58 | Value="{DynamicResource RegionBrush}" />
|
|
11 | 63 | <Setter Property="CornerRadius"
|
12 | 64 | Value="{StaticResource DefaultCornerRadius}" />
|
13 | 65 | <Setter Property="Padding"
|
14 |
| - Value="4" /> |
| 66 | + Value="2,2,2,0" /> |
15 | 67 | <Setter Property="ScrollViewer.HorizontalScrollBarVisibility"
|
16 | 68 | Value="Auto" />
|
17 | 69 | <Setter Property="ScrollViewer.VerticalScrollBarVisibility"
|
18 | 70 | Value="Auto" />
|
19 | 71 | <Setter Property="ScrollViewer.IsScrollChainingEnabled"
|
20 | 72 | Value="True" />
|
| 73 | + <Setter Property="ItemContainerTheme" |
| 74 | + Value="{StaticResource ListBoxItemBaseStyle}" /> |
| 75 | + <Setter Property="hc:BorderElement.CornerRadius" |
| 76 | + Value="{StaticResource DefaultCornerRadius}" /> |
21 | 77 | <Setter Property="Template">
|
22 | 78 | <ControlTemplate>
|
23 | 79 | <Border Name="border"
|
24 | 80 | BorderBrush="{TemplateBinding BorderBrush}"
|
25 | 81 | BorderThickness="{TemplateBinding BorderThickness}"
|
| 82 | + Background="{TemplateBinding Background}" |
26 | 83 | CornerRadius="{TemplateBinding CornerRadius}">
|
27 | 84 | <ScrollViewer Name="PART_ScrollViewer"
|
28 | 85 | AllowAutoHide="{TemplateBinding (ScrollViewer.AllowAutoHide)}"
|
29 | 86 | BringIntoViewOnFocusChange="{TemplateBinding (ScrollViewer.BringIntoViewOnFocusChange)}"
|
30 |
| - Background="{TemplateBinding Background}" |
31 | 87 | HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}"
|
32 | 88 | IsScrollChainingEnabled="{TemplateBinding (ScrollViewer.IsScrollChainingEnabled)}"
|
33 | 89 | IsDeferredScrollingEnabled="{TemplateBinding (ScrollViewer.IsDeferredScrollingEnabled)}"
|
|
42 | 98 | </ControlTemplate>
|
43 | 99 | </Setter>
|
44 | 100 | </ControlTheme>
|
| 101 | + |
| 102 | + <ControlTheme x:Key="{x:Type ListBox}" |
| 103 | + BasedOn="{StaticResource ListBoxBaseStyle}" |
| 104 | + TargetType="ListBox" /> |
| 105 | + |
| 106 | + <ControlTheme x:Key="ListBoxItemBaseStyle.Small" |
| 107 | + BasedOn="{StaticResource ListBoxItemBaseStyle}" |
| 108 | + TargetType="ListBoxItem"> |
| 109 | + <Setter Property="Padding" |
| 110 | + Value="6,0" /> |
| 111 | + <Setter Property="MinHeight" |
| 112 | + Value="24" /> |
| 113 | + </ControlTheme> |
| 114 | + |
| 115 | + <ControlTheme x:Key="ListBox.Small" |
| 116 | + BasedOn="{StaticResource ListBoxBaseStyle}" |
| 117 | + TargetType="ListBox"> |
| 118 | + <Setter Property="ItemContainerTheme" |
| 119 | + Value="{StaticResource ListBoxItemBaseStyle.Small}" /> |
| 120 | + </ControlTheme> |
45 | 121 | </ResourceDictionary>
|
0 commit comments