Skip to content

Commit 4d981ff

Browse files
committed
fix number box
fix #186
1 parent 1cb363b commit 4d981ff

2 files changed

Lines changed: 75 additions & 23 deletions

File tree

source/iNKORE.UI.WPF.Modern.Controls/Controls/Windows/NumberBox/NumberBox.xaml

Lines changed: 72 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
xmlns:local="clr-namespace:iNKORE.UI.WPF.Modern.Controls"
66
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
77
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
8-
xmlns:common="clr-namespace:iNKORE.UI.WPF.Modern.Common;assembly=iNKORE.UI.WPF.Modern">
8+
xmlns:common="clr-namespace:iNKORE.UI.WPF.Modern.Common;assembly=iNKORE.UI.WPF.Modern"
9+
xmlns:sys="clr-namespace:System;assembly=netstandard">
910

1011
<ResourceDictionary.MergedDictionaries>
1112
<ResourceDictionary Source="/iNKORE.UI.WPF.Modern;component/Themes/Controls/RepeatButton.xaml" />
@@ -19,6 +20,7 @@
1920
<ikw:CornerRadiusFilterConverter x:Key="BottomCornerRadiusFilterConverter" Filter="Bottom" />
2021
<ikw:CornerRadiusFilterConverter x:Key="LeftCornerRadiusFilterConverter" Filter="Left" />
2122

23+
<sys:Double x:Key="NumberBoxMinWidth">120</sys:Double>
2224
<Thickness x:Key="NumberBoxPopupIndicatorMargin">0,0,8,0</Thickness>
2325

2426
<Style
@@ -27,9 +29,11 @@
2729
TargetType="RepeatButton">
2830
<Style.Setters>
2931
<Setter Property="IsTabStop" Value="False" />
30-
<Setter Property="MinWidth" Value="34" />
32+
<Setter Property="MinWidth" Value="32" />
33+
<Setter Property="Padding" Value="0" />
3134
<Setter Property="VerticalAlignment" Value="Stretch" />
32-
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
35+
<Setter Property="FontSize" Value="12" />
36+
<Setter Property="Background" Value="Transparent" />
3337
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}" />
3438
<Setter Property="BorderThickness" Value="{DynamicResource NumberBoxSpinButtonBorderThickness}" />
3539
<Setter Property="FontFamily" Value="{DynamicResource SymbolThemeFontFamily}" />
@@ -45,15 +49,17 @@
4549

4650
<Style
4751
x:Key="NumberBoxPopupSpinButtonStyle"
48-
BasedOn="{StaticResource DefaultRepeatButtonStyle}"
52+
BasedOn="{StaticResource NumberBoxSpinButtonStyle}"
4953
TargetType="RepeatButton">
5054
<Style.Setters>
5155
<Setter Property="Focusable" Value="False" />
52-
<Setter Property="Width" Value="40" />
53-
<Setter Property="Height" Value="32" />
54-
<Setter Property="Background" Value="{DynamicResource NumberBoxPopupSpinButtonBackground}" />
56+
<Setter Property="Width" Value="36" />
57+
<Setter Property="Height" Value="36" />
58+
<Setter Property="Padding" Value="0" />
5559
<Setter Property="BorderThickness" Value="{DynamicResource NumberBoxPopupSpinButtonBorderThickness}" />
60+
<Setter Property="FontSize" Value="16" />
5661
<Setter Property="FontFamily" Value="{DynamicResource SymbolThemeFontFamily}" />
62+
<Setter Property="ui:ControlHelper.CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
5763
<Setter Property="ContentTemplate">
5864
<Setter.Value>
5965
<DataTemplate>
@@ -82,7 +88,8 @@
8288
</ControlTemplate.Resources>
8389
<Border
8490
x:Name="ButtonLayoutGrid"
85-
Background="{DynamicResource TextControlButtonBackground}"
91+
Margin="{DynamicResource TextBoxInnerButtonMargin}"
92+
Background="Transparent"
8693
BorderBrush="{DynamicResource TextControlButtonBorderBrush}"
8794
BorderThickness="{TemplateBinding BorderThickness}"
8895
CornerRadius="{TemplateBinding ui:ControlHelper.CornerRadius}">
@@ -92,7 +99,7 @@
9299
VerticalAlignment="Center"
93100
Data="{StaticResource Cancel}"
94101
FontFamily="{DynamicResource SymbolThemeFontFamily}"
95-
FontSize="12"
102+
FontSize="{DynamicResource TextBoxIconFontSize}"
96103
FontStyle="Normal"
97104
Foreground="{DynamicResource TextControlButtonForeground}" />
98105
</Border>
@@ -125,7 +132,7 @@
125132
<Grid.ColumnDefinitions>
126133
<ColumnDefinition Width="*" />
127134
<ColumnDefinition Width="Auto" />
128-
<ColumnDefinition Width="Auto" />
135+
<ColumnDefinition x:Name="SpinButtonsColumn" Width="Auto" />
129136
</Grid.ColumnDefinitions>
130137
<ui:ContentPresenterEx
131138
x:Name="HeaderContentPresenter"
@@ -204,6 +211,7 @@
204211
TextElement.Foreground="{DynamicResource SystemControlDescriptionTextForegroundBrush}"
205212
Visibility="{TemplateBinding ui:ControlHelper.DescriptionVisibility}" />
206213
<ui:FontIconFallback
214+
x:Name="PopupIndicator"
207215
Grid.Row="1"
208216
Grid.Column="2"
209217
Margin="{StaticResource NumberBoxPopupIndicatorMargin}"
@@ -212,6 +220,7 @@
212220
Data="{StaticResource ScrollUpDown}"
213221
FontFamily="{DynamicResource SymbolThemeFontFamily}"
214222
FontSize="12"
223+
Visibility="Collapsed"
215224
Foreground="{DynamicResource NumberBoxPopupIndicatorForeground}" />
216225
<VisualStateManager.VisualStateGroups>
217226
<VisualStateGroup x:Name="ButtonStates">
@@ -227,6 +236,14 @@
227236
</VisualStateManager.VisualStateGroups>
228237
</Grid>
229238
<ControlTemplate.Triggers>
239+
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:NumberBox}, Path=SpinButtonPlacementMode, Mode=OneWay}" Value="Inline">
240+
<Setter TargetName="SpinButtonsColumn" Property="Width" Value="72"/>
241+
</DataTrigger>
242+
243+
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:NumberBox}, Path=SpinButtonPlacementMode, Mode=OneWay}" Value="Compact">
244+
<Setter TargetName="PopupIndicator" Property="Visibility" Value="Visible"/>
245+
</DataTrigger>
246+
230247
<Trigger Property="ui:ControlHelper.PlaceholderForeground" Value="{x:Null}">
231248
<Setter TargetName="PlaceholderTextContentPresenter" Property="Foreground" Value="{DynamicResource TextControlPlaceholderForeground}" />
232249
</Trigger>
@@ -271,10 +288,17 @@
271288

272289
<Style TargetType="local:NumberBox">
273290
<Setter Property="IsTabStop" Value="False" />
291+
<Setter Property="VerticalAlignment" Value="Top" />
292+
<Setter Property="HorizontalAlignment" Value="Left" />
293+
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
294+
<Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" />
295+
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}" />
296+
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
274297
<Setter Property="SelectionBrush" Value="{DynamicResource TextControlSelectionHighlightColor}" />
275298
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
276299
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
277300
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
301+
<Setter Property="Padding" Value="{DynamicResource TextControlThemePadding}" />
278302
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
279303
<Setter Property="Template">
280304
<Setter.Value>
@@ -284,7 +308,7 @@
284308
<StreamGeometry x:Key="ChevronUp">M 19.091797 14.970703 L 10 5.888672 L 0.908203 14.970703 L 0.029297 14.091797 L 10 4.111328 L 19.970703 14.091797 Z</StreamGeometry>
285309
</ControlTemplate.Resources>
286310

287-
<Grid ui:ThemeManager.HasThemeResources="True">
311+
<Grid ui:ThemeManager.HasThemeResources="True" Height="{TemplateBinding Height}">
288312
<Grid.Resources>
289313
<ui:ResourceDictionaryEx>
290314
<!--<ui:ResourceDictionaryEx.ThemeDictionaries>
@@ -306,13 +330,13 @@
306330
<ui:StaticResource x:Key="RepeatButtonBorderBrushPointerOver" ResourceKey="TextControlBorderBrush" />
307331
<ui:StaticResource x:Key="RepeatButtonBorderBrushPressed" ResourceKey="TextControlBorderBrush" />
308332

309-
333+
310334
</ui:ResourceDictionaryEx>
311335
</Grid.Resources>
312336

313337
<Grid.RowDefinitions>
314338
<RowDefinition Height="Auto" />
315-
<RowDefinition Height="Auto" />
339+
<RowDefinition Height="*" />
316340
<RowDefinition Height="Auto" />
317341
</Grid.RowDefinitions>
318342

@@ -340,14 +364,21 @@
340364
<TextBox
341365
x:Name="InputBox"
342366
Grid.Row="1"
367+
Grid.ColumnSpan="3"
343368
ui:ControlHelper.CornerRadius="{TemplateBinding CornerRadius}"
344369
ui:ControlHelper.PlaceholderText="{TemplateBinding PlaceholderText}"
345370
FontFamily="{TemplateBinding FontFamily}"
346371
FontSize="{TemplateBinding FontSize}"
347372
FontWeight="{TemplateBinding FontWeight}"
348373
InputScope="{TemplateBinding InputScope}"
349374
SelectionBrush="{TemplateBinding SelectionBrush}"
350-
TextAlignment="{TemplateBinding TextAlignment}" />
375+
Background="{TemplateBinding Background}"
376+
BorderThickness="{TemplateBinding BorderThickness}"
377+
BorderBrush="{TemplateBinding BorderBrush}"
378+
Padding="{TemplateBinding Padding}"
379+
Foreground="{TemplateBinding Foreground}"
380+
TextAlignment="{TemplateBinding TextAlignment}"
381+
Style="{StaticResource NumberBoxTextBoxStyle}"/>
351382

352383
<Popup
353384
x:Name="UpDownPopup"
@@ -365,6 +396,7 @@
365396
IsShadowEnabled="{DynamicResource {x:Static SystemParameters.DropShadowKey}}">
366397
<Border
367398
x:Name="PopupContentRoot"
399+
Padding="6"
368400
Background="{DynamicResource NumberBoxPopupBackground}"
369401
BorderBrush="{DynamicResource NumberBoxPopupBorderBrush}"
370402
BorderThickness="{DynamicResource NumberBoxPopupBorderThickness}"
@@ -379,6 +411,7 @@
379411
<RepeatButton
380412
x:Name="PopupUpSpinButton"
381413
Content="{StaticResource ChevronUp}"
414+
Margin="0,0,0,4"
382415
Style="{StaticResource NumberBoxPopupSpinButtonStyle}" />
383416

384417
<RepeatButton
@@ -391,11 +424,28 @@
391424
</ui:ThemeShadowChrome>
392425
</Popup>
393426

427+
<Button x:Name="InputEater"
428+
Grid.Row="1"
429+
Grid.Column="1"
430+
Grid.ColumnSpan="2"
431+
Visibility="Collapsed"
432+
HorizontalAlignment="Stretch"
433+
VerticalAlignment="Stretch"
434+
Margin="4,0,0,0"
435+
IsTabStop="False">
436+
<Button.Template>
437+
<ControlTemplate TargetType="Button">
438+
<Grid Background="Transparent" />
439+
</ControlTemplate>
440+
</Button.Template>
441+
</Button>
442+
394443
<RepeatButton
395444
x:Name="UpSpinButton"
396445
Grid.Row="1"
397446
Grid.Column="1"
398-
ui:ControlHelper.CornerRadius="0"
447+
Margin="4"
448+
ui:ControlHelper.CornerRadius="{TemplateBinding CornerRadius}"
399449
Content="{StaticResource ChevronUp}"
400450
FontSize="{TemplateBinding FontSize}"
401451
Style="{StaticResource NumberBoxSpinButtonStyle}"
@@ -405,8 +455,8 @@
405455
x:Name="DownSpinButton"
406456
Grid.Row="1"
407457
Grid.Column="2"
408-
ui:ControlHelper.CornerRadius="{TemplateBinding CornerRadius,
409-
Converter={StaticResource RightCornerRadiusFilterConverter}}"
458+
ui:ControlHelper.CornerRadius="{TemplateBinding CornerRadius}"
459+
Margin="0,4,4,4"
410460
Content="{StaticResource ChevronDown}"
411461
FontSize="{TemplateBinding FontSize}"
412462
Style="{StaticResource NumberBoxSpinButtonStyle}"
@@ -415,7 +465,7 @@
415465
<ContentPresenter
416466
x:Name="DescriptionPresenter"
417467
Grid.Row="2"
418-
Grid.ColumnSpan="2"
468+
Grid.ColumnSpan="3"
419469
Content="{TemplateBinding Description}"
420470
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
421471
TextElement.Foreground="{DynamicResource SystemControlDescriptionTextForegroundBrush}"
@@ -461,14 +511,16 @@
461511
</VisualStateManager.VisualStateGroups>
462512
</Grid>
463513
<ControlTemplate.Triggers>
464-
<Trigger Property="IsEnabled" Value="false">
514+
<Trigger Property="IsEnabled" Value="False">
465515
<Setter TargetName="HeaderContentPresenter" Property="Foreground" Value="{DynamicResource TextControlHeaderForegroundDisabled}" />
466516
</Trigger>
467517
<!-- SpinButtonsVisible -->
468518
<Trigger Property="SpinButtonPlacementMode" Value="Inline">
469519
<Setter TargetName="DownSpinButton" Property="Visibility" Value="Visible" />
470520
<Setter TargetName="UpSpinButton" Property="Visibility" Value="Visible" />
471-
<Setter TargetName="InputBox" Property="ui:ControlHelper.CornerRadius" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius, Converter={StaticResource LeftCornerRadiusFilterConverter}}" />
521+
<Setter TargetName="InputEater" Property="Visibility" Value="Visible" />
522+
<!--<Setter TargetName="InputBox" Property="ui:ControlHelper.CornerRadius" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius, Converter={StaticResource LeftCornerRadiusFilterConverter}}" />-->
523+
<Setter TargetName="InputBox" Property="MinWidth" Value="{StaticResource NumberBoxMinWidth}" />
472524
</Trigger>
473525
<!-- SpinButtonsPopup -->
474526
<Trigger Property="SpinButtonPlacementMode" Value="Compact">

source/iNKORE.UI.WPF.Modern/Themes/ControlsResources.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@
6565
<sys:Double x:Key="GridViewItemMinHeight">44</sys:Double>
6666
<sys:Double x:Key="ListViewItemMinWidth">88</sys:Double>
6767
<sys:Double x:Key="ListViewItemMinHeight">40</sys:Double>
68-
<sys:Double x:Key="NumberBoxPopupHorizonalOffset">-20</sys:Double>
69-
<sys:Double x:Key="NumberBoxPopupVerticalOffset">-16</sys:Double>
68+
<sys:Double x:Key="NumberBoxPopupHorizonalOffset">-21</sys:Double>
69+
<sys:Double x:Key="NumberBoxPopupVerticalOffset">-27</sys:Double>
7070
<sys:Double x:Key="NumberBoxPopupShadowDepth">16</sys:Double>
7171
<sys:Double x:Key="RadioButtonsColumnSpacing">7</sys:Double>
7272
<sys:Double x:Key="RadioButtonsRowSpacing">3</sys:Double>
7373
<sys:Double x:Key="TextControlThemeMinHeight">32</sys:Double>
74-
<Thickness x:Key="NumberBoxSpinButtonBorderThickness">0,1,1,1</Thickness>
74+
<Thickness x:Key="NumberBoxSpinButtonBorderThickness">0</Thickness>
7575
<Thickness x:Key="NumberBoxIconMargin">10,0,0,0</Thickness>
7676
<Thickness x:Key="RadioButtonsTopHeaderMargin">0,0,0,4</Thickness>
7777
<Thickness x:Key="TextControlThemePadding">10,5,6,6</Thickness>

0 commit comments

Comments
 (0)