|
1 | | -<!-- |
| 1 | +<!-- |
2 | 2 | This Source Code Form is subject to the terms of the MIT License. |
3 | 3 | If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. |
4 | 4 | Copyright (C) Leszek Pomianowski and WPF UI Contributors. |
|
12 | 12 | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
13 | 13 | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
14 | 14 | xmlns:controls="clr-namespace:Wpf.Ui.Controls" |
| 15 | + xmlns:converters="clr-namespace:Wpf.Ui.Converters" |
15 | 16 | xmlns:system="clr-namespace:System;assembly=mscorlib"> |
16 | 17 |
|
| 18 | + <ResourceDictionary.MergedDictionaries> |
| 19 | + <ResourceDictionary Source="pack://application:,,,/Wpf.Ui;component/Controls/TextBox/TextBox.xaml" /> |
| 20 | + </ResourceDictionary.MergedDictionaries> |
| 21 | + |
17 | 22 | <Thickness x:Key="DatePickerBorderThemeThickness">1,1,1,0</Thickness> |
18 | 23 | <Thickness x:Key="DatePickerAccentBorderThemeThickness">0,0,0,1</Thickness> |
19 | 24 | <Thickness x:Key="DatePickerLeftIconMargin">10,8,0,0</Thickness> |
20 | 25 | <Thickness x:Key="DatePickerRightIconMargin">0,8,10,0</Thickness> |
21 | | - <Thickness x:Key="DatePickerCalendarButtonMargin">0,5,4,0</Thickness> |
| 26 | + <Thickness x:Key="DatePickerCalendarButtonMargin">0,6,4,6</Thickness> |
22 | 27 | <Thickness x:Key="DatePickerCalendarButtonPadding">0,0,0,0</Thickness> |
23 | 28 | <system:Double x:Key="DatePickerCalendarButtonHeight">24</system:Double> |
24 | 29 | <system:Double x:Key="DatePickerCalendarButtonIconSize">14</system:Double> |
25 | 30 |
|
26 | | - <Style x:Key="DefaultDatePickerTextBoxStyle" TargetType="{x:Type DatePickerTextBox}"> |
27 | | - <!-- Universal WPF UI focus --> |
28 | | - <Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" /> |
29 | | - <!-- Universal WPF UI focus --> |
30 | | - <Setter Property="BorderThickness" Value="0" /> |
31 | | - <Setter Property="HorizontalContentAlignment" Value="Stretch" /> |
32 | | - <Setter Property="VerticalContentAlignment" Value="Stretch" /> |
33 | | - <Setter Property="BorderBrush" Value="Transparent" /> |
34 | | - <Setter Property="Background" Value="Transparent" /> |
35 | | - <Setter Property="Foreground"> |
36 | | - <Setter.Value> |
37 | | - <SolidColorBrush Color="{DynamicResource TextFillColorPrimary}" /> |
38 | | - </Setter.Value> |
39 | | - </Setter> |
40 | | - <Setter Property="CaretBrush"> |
41 | | - <Setter.Value> |
42 | | - <SolidColorBrush Color="{DynamicResource TextFillColorPrimary}" /> |
43 | | - </Setter.Value> |
44 | | - </Setter> |
45 | | - <Setter Property="SnapsToDevicePixels" Value="True" /> |
46 | | - <Setter Property="OverridesDefaultStyle" Value="True" /> |
47 | | - <Setter Property="Template"> |
48 | | - <Setter.Value> |
49 | | - <ControlTemplate TargetType="{x:Type DatePickerTextBox}"> |
50 | | - <Border Margin="{TemplateBinding Margin}"> |
51 | | - <Decorator x:Name="PART_ContentHost" Margin="{TemplateBinding Padding}" /> |
52 | | - </Border> |
53 | | - </ControlTemplate> |
54 | | - </Setter.Value> |
55 | | - </Setter> |
| 31 | + <converters:DatePickerButtonPaddingConverter x:Key="DatePickerButtonPaddingConverter" /> |
| 32 | + |
| 33 | + <Style |
| 34 | + x:Key="DefaultDatePickerTextBoxStyle" |
| 35 | + BasedOn="{StaticResource DefaultTextBoxStyle}" |
| 36 | + TargetType="{x:Type DatePickerTextBox}"> |
| 37 | + <Setter Property="Border.CornerRadius" Value="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" /> |
56 | 38 | </Style> |
57 | 39 |
|
58 | 40 | <Style x:Key="DefaultDatePickerStyle" TargetType="{x:Type DatePicker}"> |
59 | | - <!-- Universal WPF UI focus --> |
60 | | - <Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" /> |
61 | | - <!-- Universal WPF UI focus --> |
62 | 41 | <!-- Universal WPF UI ContextMenu --> |
63 | 42 | <Setter Property="ContextMenu" Value="{DynamicResource DefaultControlContextMenu}" /> |
64 | 43 | <!-- Universal WPF UI ContextMenu --> |
65 | 44 | <!-- Default WPF UI Calendar style --> |
66 | | - <Setter Property="CalendarStyle" Value="{DynamicResource DefaultCalendarStyle}" /> |
| 45 | + <Setter Property="CalendarStyle" Value="{DynamicResource DefaultCalendarDropShadowStyle}" /> |
67 | 46 | <!-- Default WPF UI Calendar style --> |
68 | 47 | <Setter Property="Foreground"> |
69 | 48 | <Setter.Value> |
|
81 | 60 | <Setter Property="HorizontalAlignment" Value="Stretch" /> |
82 | 61 | <Setter Property="VerticalAlignment" Value="Center" /> |
83 | 62 | <Setter Property="HorizontalContentAlignment" Value="Stretch" /> |
84 | | - <Setter Property="VerticalContentAlignment" Value="Top" /> |
| 63 | + <Setter Property="VerticalContentAlignment" Value="Stretch" /> |
85 | 64 | <Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" /> |
86 | 65 | <Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" /> |
87 | 66 | <Setter Property="Padding" Value="{DynamicResource TextControlThemePadding}" /> |
88 | 67 | <Setter Property="Border.CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> |
89 | 68 | <Setter Property="SnapsToDevicePixels" Value="True" /> |
90 | 69 | <Setter Property="OverridesDefaultStyle" Value="True" /> |
| 70 | + <Setter Property="KeyboardNavigation.TabNavigation" Value="Local" /> |
91 | 71 | <Setter Property="Template"> |
92 | 72 | <Setter.Value> |
93 | 73 | <ControlTemplate TargetType="{x:Type DatePicker}"> |
|
100 | 80 | Grid.Row="0" |
101 | 81 | HorizontalAlignment="{TemplateBinding HorizontalAlignment}" |
102 | 82 | VerticalAlignment="{TemplateBinding VerticalAlignment}"> |
103 | | - <Border |
104 | | - x:Name="ContentBorder" |
| 83 | + <DatePickerTextBox |
| 84 | + x:Name="PART_TextBox" |
105 | 85 | MinWidth="{TemplateBinding MinWidth}" |
106 | 86 | MinHeight="{TemplateBinding MinHeight}" |
107 | | - Padding="0" |
108 | 87 | HorizontalAlignment="Stretch" |
109 | 88 | VerticalAlignment="Stretch" |
110 | | - Background="{TemplateBinding Background}" |
| 89 | + HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
| 90 | + VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
111 | 91 | BorderBrush="{TemplateBinding BorderBrush}" |
112 | 92 | BorderThickness="{TemplateBinding BorderThickness}" |
113 | | - CornerRadius="{TemplateBinding Border.CornerRadius}"> |
114 | | - <Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"> |
115 | | - <Grid.ColumnDefinitions> |
116 | | - <ColumnDefinition Width="*" /> |
117 | | - <ColumnDefinition Width="Auto" /> |
118 | | - </Grid.ColumnDefinitions> |
119 | | - <Grid Grid.Column="0"> |
120 | | - <DatePickerTextBox |
121 | | - x:Name="PART_TextBox" |
122 | | - Margin="0" |
123 | | - Padding="{TemplateBinding Padding}" |
124 | | - HorizontalAlignment="Stretch" |
125 | | - VerticalAlignment="Stretch" |
126 | | - ContextMenu="{TemplateBinding ContextMenu}" |
127 | | - Focusable="{TemplateBinding Focusable}" |
128 | | - Foreground="{TemplateBinding Foreground}" /> |
129 | | - </Grid> |
130 | | - <!-- Buttons and Icons have no padding from the main element to allow absolute positions if height is larger than the text entry zone --> |
131 | | - <controls:Button |
132 | | - x:Name="PART_Button" |
133 | | - Grid.Column="1" |
134 | | - Width="{StaticResource DatePickerCalendarButtonHeight}" |
135 | | - Height="{StaticResource DatePickerCalendarButtonHeight}" |
136 | | - Margin="{StaticResource DatePickerCalendarButtonMargin}" |
137 | | - Padding="{StaticResource DatePickerCalendarButtonPadding}" |
138 | | - HorizontalAlignment="Center" |
139 | | - VerticalAlignment="Top" |
140 | | - HorizontalContentAlignment="Center" |
141 | | - VerticalContentAlignment="Center" |
142 | | - Appearance="Secondary" |
143 | | - Background="Transparent" |
144 | | - BorderBrush="Transparent" |
145 | | - Cursor="Arrow"> |
146 | | - <!-- WPF overrides paddings for button --> |
147 | | - <controls:SymbolIcon |
148 | | - Margin="{StaticResource DatePickerCalendarButtonPadding}" |
149 | | - HorizontalAlignment="Center" |
150 | | - VerticalAlignment="Center" |
151 | | - FontSize="{StaticResource DatePickerCalendarButtonIconSize}" |
152 | | - Foreground="{TemplateBinding Foreground}" |
153 | | - Symbol="CalendarRtl24" /> |
154 | | - </controls:Button> |
155 | | - </Grid> |
156 | | - </Border> |
| 93 | + ContextMenu="{TemplateBinding ContextMenu}" |
| 94 | + Focusable="{TemplateBinding Focusable}" |
| 95 | + FontFamily="{TemplateBinding FontFamily}" |
| 96 | + FontSize="{TemplateBinding FontSize}" |
| 97 | + Foreground="{TemplateBinding Foreground}" |
| 98 | + KeyboardNavigation.TabIndex="0" |
| 99 | + Tag="{TemplateBinding Border.CornerRadius}"> |
| 100 | + <DatePickerTextBox.Padding> |
| 101 | + <MultiBinding Converter="{StaticResource DatePickerButtonPaddingConverter}"> |
| 102 | + <Binding Path="Padding" RelativeSource="{RelativeSource Mode=TemplatedParent}" /> |
| 103 | + <Binding Source="{StaticResource DatePickerCalendarButtonMargin}" /> |
| 104 | + <Binding Source="{StaticResource DatePickerCalendarButtonHeight}" /> |
| 105 | + </MultiBinding> |
| 106 | + </DatePickerTextBox.Padding> |
| 107 | + </DatePickerTextBox> |
| 108 | + <!-- Buttons and Icons have no padding from the main element to allow absolute positions if height is larger than the text entry zone --> |
| 109 | + <controls:Button |
| 110 | + x:Name="PART_Button" |
| 111 | + Width="{StaticResource DatePickerCalendarButtonHeight}" |
| 112 | + Height="{StaticResource DatePickerCalendarButtonHeight}" |
| 113 | + Margin="{StaticResource DatePickerCalendarButtonMargin}" |
| 114 | + Padding="{StaticResource DatePickerCalendarButtonPadding}" |
| 115 | + HorizontalAlignment="Right" |
| 116 | + VerticalAlignment="Stretch" |
| 117 | + HorizontalContentAlignment="Center" |
| 118 | + VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
| 119 | + Appearance="Secondary" |
| 120 | + Background="Transparent" |
| 121 | + BorderBrush="Transparent" |
| 122 | + Cursor="Arrow" |
| 123 | + KeyboardNavigation.TabIndex="1" |
| 124 | + MouseOverBackground="{DynamicResource SubtleFillColorSecondaryBrush}" |
| 125 | + MouseOverBorderBrush="Transparent" |
| 126 | + PressedBackground="{DynamicResource SubtleFillColorTertiaryBrush}" |
| 127 | + PressedBorderBrush="Transparent"> |
| 128 | + <!-- WPF overrides paddings for button --> |
| 129 | + <controls:SymbolIcon |
| 130 | + Margin="{StaticResource DatePickerCalendarButtonPadding}" |
| 131 | + HorizontalAlignment="Center" |
| 132 | + VerticalAlignment="Center" |
| 133 | + FontSize="{StaticResource DatePickerCalendarButtonIconSize}" |
| 134 | + Foreground="{TemplateBinding Foreground}" |
| 135 | + Symbol="CalendarRtl24" /> |
| 136 | + </controls:Button> |
157 | 137 | <!-- The Accent Border is a separate element so that changes to the border thickness do not affect the position of the element --> |
158 | 138 | <Border |
159 | 139 | x:Name="AccentBorder" |
160 | 140 | HorizontalAlignment="Stretch" |
161 | 141 | VerticalAlignment="Stretch" |
| 142 | + BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}" |
162 | 143 | BorderThickness="{StaticResource DatePickerAccentBorderThemeThickness}" |
163 | | - CornerRadius="{TemplateBinding Border.CornerRadius}"> |
164 | | - <Border.BorderBrush> |
165 | | - <SolidColorBrush Color="{DynamicResource ControlStrongStrokeColorDefault}" /> |
166 | | - </Border.BorderBrush> |
167 | | - </Border> |
| 144 | + CornerRadius="{TemplateBinding Border.CornerRadius}" /> |
168 | 145 | </Grid> |
169 | 146 | <Popup |
170 | 147 | x:Name="PART_Popup" |
171 | 148 | Grid.Row="1" |
172 | 149 | HorizontalAlignment="Stretch" |
173 | 150 | VerticalAlignment="Top" |
174 | 151 | AllowsTransparency="True" |
175 | | - Placement="Mouse" |
| 152 | + Placement="Bottom" |
176 | 153 | PlacementTarget="{Binding ElementName=PART_TextBox}" |
177 | 154 | StaysOpen="False" /> |
178 | 155 | </Grid> |
179 | 156 | <ControlTemplate.Triggers> |
180 | | - <Trigger Property="IsKeyboardFocusWithin" Value="True"> |
181 | | - <Setter TargetName="AccentBorder" Property="BorderThickness" Value="0,0,0,2" /> |
182 | | - <Setter TargetName="AccentBorder" Property="BorderBrush"> |
183 | | - <Setter.Value> |
184 | | - <SolidColorBrush Color="{DynamicResource SystemAccentColorSecondary}" /> |
185 | | - </Setter.Value> |
186 | | - </Setter> |
187 | | - <Setter TargetName="ContentBorder" Property="Background"> |
188 | | - <Setter.Value> |
189 | | - <SolidColorBrush Color="{DynamicResource ControlFillColorInputActive}" /> |
190 | | - </Setter.Value> |
191 | | - </Setter> |
192 | | - </Trigger> |
193 | | - <MultiTrigger> |
194 | | - <MultiTrigger.Conditions> |
195 | | - <Condition Property="IsEnabled" Value="True" /> |
196 | | - <Condition Property="IsMouseOver" Value="True" /> |
197 | | - <Condition Property="IsKeyboardFocusWithin" Value="False" /> |
198 | | - </MultiTrigger.Conditions> |
199 | | - <Setter TargetName="ContentBorder" Property="Background"> |
200 | | - <Setter.Value> |
201 | | - <SolidColorBrush Color="{DynamicResource ControlFillColorSecondary}" /> |
202 | | - </Setter.Value> |
203 | | - </Setter> |
204 | | - </MultiTrigger> |
205 | 157 | <Trigger Property="IsEnabled" Value="True"> |
206 | 158 | <Setter Property="Cursor" Value="IBeam" /> |
207 | 159 | </Trigger> |
208 | 160 | <Trigger Property="IsEnabled" Value="False"> |
209 | | - <Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource ControlFillColorDisabledBrush}" /> |
210 | | - <Setter TargetName="ContentBorder" Property="BorderBrush" Value="{DynamicResource ControlStrokeColorDefaultBrush}" /> |
211 | | - <Setter TargetName="AccentBorder" Property="BorderBrush" Value="{DynamicResource ControlStrokeColorDefaultBrush}" /> |
212 | 161 | <Setter Property="Foreground" Value="{DynamicResource TextFillColorDisabledBrush}" /> |
213 | 162 | </Trigger> |
214 | 163 | </ControlTemplate.Triggers> |
|
0 commit comments