Skip to content

Commit bb64eaf

Browse files
Extract TextBox.Padding setters into style overrides instead of triggers
1 parent 0729bbc commit bb64eaf

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

MainDemo.Wpf/MainWindow.xaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,11 @@
6060
Width="200"
6161
Margin="16,4"
6262
materialDesign:HintAssist.Hint="Search"
63-
materialDesign:HintAssist.IsFloating="True"
6463
materialDesign:TextFieldAssist.DecorationVisibility="Collapsed"
6564
materialDesign:TextFieldAssist.HasClearButton="True"
66-
materialDesign:TextFieldAssist.HasOutlinedTextField="True"
67-
materialDesign:TextFieldAssist.TextFieldCornerRadius="4"
6865
DockPanel.Dock="Top"
69-
Text="{Binding SearchKeyword, UpdateSourceTrigger=PropertyChanged}" />
66+
Text="{Binding SearchKeyword, UpdateSourceTrigger=PropertyChanged}"
67+
Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
7068

7169
<ListBox x:Name="DemoItemsListBox"
7270
Margin="0,16,0,16"

MaterialDesignThemes.Wpf/Constants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ namespace MaterialDesignThemes.Wpf;
33
public static class Constants
44
{
55
public static readonly Thickness TextBoxDefaultPadding = new Thickness(0, 4, 0, 4);
6+
public static readonly Thickness FilledTextBoxDefaultPadding = new Thickness(16, 8, 12, 8);
7+
public static readonly Thickness OutlinedTextBoxDefaultPadding = new Thickness(16, 16, 12, 16);
68
public static readonly Thickness DefaultTextBoxViewMargin = new Thickness(1, 0, 1, 0);
79
public static readonly Thickness DefaultTextBoxViewMarginEmbedded = new Thickness(0);
810
public const double TextBoxNotEnabledOpacity = 0.56;

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TextBox.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,14 +303,12 @@
303303
</MultiTrigger>
304304
<Trigger Property="wpf:TextFieldAssist.HasFilledTextField" Value="True">
305305
<Setter Property="Background" Value="{DynamicResource MaterialDesignTextFieldBoxBackground}" />
306-
<Setter Property="Padding" Value="16,8,12,8" />
307306
<Setter TargetName="Hint" Property="wpf:TextFieldAssist.TextBoxViewMargin" Value="{x:Static wpf:Constants.DefaultTextBoxViewMarginEmbedded}" />
308307
<Setter TargetName="HelperTextTextBlock" Property="Margin" Value="16,0,0,0" />
309308
</Trigger>
310309
<Trigger Property="wpf:TextFieldAssist.HasOutlinedTextField" Value="True">
311310
<Setter Property="BorderBrush" Value="{DynamicResource MaterialDesignTextAreaBorder}" />
312311
<Setter Property="BorderThickness" Value="1" />
313-
<Setter Property="Padding" Value="16,16,12,16" />
314312
<Setter TargetName="Hint" Property="wpf:TextFieldAssist.TextBoxViewMargin" Value="{x:Static wpf:Constants.DefaultTextBoxViewMarginEmbedded}" />
315313
<Setter TargetName="HelperTextTextBlock" Property="Margin" Value="16,0,0,0" />
316314
<Setter TargetName="Hint" Property="FloatingOffset">
@@ -512,13 +510,15 @@
512510
<Setter Property="wpf:TextFieldAssist.HasFilledTextField" Value="True" />
513511
<Setter Property="wpf:TextFieldAssist.TextFieldCornerRadius" Value="4,4,0,0" />
514512
<Setter Property="wpf:TextFieldAssist.UnderlineCornerRadius" Value="0" />
513+
<Setter Property="Padding" Value="{x:Static wpf:Constants.FilledTextBoxDefaultPadding}" />
515514
</Style>
516515

517516
<Style x:Key="MaterialDesignOutlinedTextBox"
518517
TargetType="{x:Type TextBox}"
519518
BasedOn="{StaticResource MaterialDesignFloatingHintTextBox}">
520519
<Setter Property="wpf:TextFieldAssist.HasOutlinedTextField" Value="True" />
521520
<Setter Property="wpf:TextFieldAssist.TextFieldCornerRadius" Value="4" />
521+
<Setter Property="Padding" Value="{x:Static wpf:Constants.OutlinedTextBoxDefaultPadding}" />
522522
</Style>
523523

524524
</ResourceDictionary>

0 commit comments

Comments
 (0)