Skip to content

Commit b8fba1b

Browse files
authored
Fix #2633 - HelperText margin and padding (#2648)
* Transparent header menu * Filling the available height with menu headers + additional menu examples in the demo * Fix HelperText padding and margin on : - FilledPassword - FilledDatePicker - OutlinedPassword - OutlinedDatePicker - OutlinedComboBox + add examples in Demo * set TextFieldAssist.HasFilledTextField to true in MaterialDesignFilledComboBox style
1 parent 94e57da commit b8fba1b

File tree

6 files changed

+73
-6
lines changed

6 files changed

+73
-6
lines changed

MainDemo.Wpf/ComboBoxes.xaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,21 @@
311311
</ComboBox.SelectedItem>
312312
</ComboBox>
313313
</smtx:XamlDisplay>
314+
315+
<smtx:XamlDisplay
316+
UniqueKey="comboboxes_helpertext_filled_combobox"
317+
HorizontalAlignment="Left">
318+
319+
<ComboBox
320+
Style="{StaticResource MaterialDesignFilledComboBox}"
321+
materialDesign:HintAssist.Hint="With helper text"
322+
materialDesign:HintAssist.HelperText="Helper text"
323+
Width="256">
324+
<ComboBoxItem Content="Item 1"/>
325+
<ComboBoxItem Content="Item 2"/>
326+
<ComboBoxItem Content="Item 3"/>
327+
</ComboBox>
328+
</smtx:XamlDisplay>
314329
</StackPanel>
315330

316331
<TextBlock
@@ -375,6 +390,21 @@
375390
</ComboBox.SelectedItem>
376391
</ComboBox>
377392
</smtx:XamlDisplay>
393+
394+
<smtx:XamlDisplay
395+
UniqueKey="comboboxes_helpertext_outlined_combobox"
396+
HorizontalAlignment="Left">
397+
398+
<ComboBox
399+
Style="{StaticResource MaterialDesignOutlinedComboBox}"
400+
materialDesign:HintAssist.Hint="With helper text"
401+
materialDesign:HintAssist.HelperText="Helper text"
402+
Width="256">
403+
<ComboBoxItem Content="Item 1"/>
404+
<ComboBoxItem Content="Item 2"/>
405+
<ComboBoxItem Content="Item 3"/>
406+
</ComboBox>
407+
</smtx:XamlDisplay>
378408
</StackPanel>
379409
</StackPanel>
380410
</UserControl>

MainDemo.Wpf/Fields.xaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@
302302
<ColumnDefinition Width="Auto"/>
303303
<ColumnDefinition Width="Auto"/>
304304
<ColumnDefinition Width="Auto"/>
305+
<ColumnDefinition Width="Auto"/>
305306
</Grid.ColumnDefinitions>
306307

307308
<Grid.Resources>
@@ -377,6 +378,17 @@
377378
materialDesign:HintAssist.Hint="Password"/>
378379
</StackPanel>
379380
</smtx:XamlDisplay>
381+
382+
<smtx:XamlDisplay
383+
Grid.Row="1"
384+
Grid.Column="4"
385+
UniqueKey="passwordFilled1"
386+
VerticalAlignment="Bottom">
387+
<PasswordBox
388+
Style="{StaticResource MaterialDesignFilledPasswordBox}"
389+
materialDesign:HintAssist.Hint="Password"
390+
materialDesign:HintAssist.HelperText="Helper text"/>
391+
</smtx:XamlDisplay>
380392
</Grid>
381393

382394
<Grid Margin="0 48 0 0">
@@ -389,6 +401,7 @@
389401
<ColumnDefinition Width="Auto"/>
390402
<ColumnDefinition Width="Auto"/>
391403
<ColumnDefinition Width="Auto"/>
404+
<ColumnDefinition Width="Auto"/>
392405
</Grid.ColumnDefinitions>
393406

394407
<Grid.Resources>
@@ -470,6 +483,17 @@
470483
materialDesign:HintAssist.Hint="Password"/>
471484
</StackPanel>
472485
</smtx:XamlDisplay>
486+
487+
<smtx:XamlDisplay
488+
Grid.Row="1"
489+
Grid.Column="4"
490+
UniqueKey="passwordOutlined1"
491+
Margin="0 34 0 0">
492+
<PasswordBox
493+
Style="{StaticResource MaterialDesignOutlinedPasswordBox}"
494+
materialDesign:HintAssist.Hint="Password"
495+
materialDesign:HintAssist.HelperText="Helper text"/>
496+
</smtx:XamlDisplay>
473497
</Grid>
474498

475499
<Grid

MainDemo.Wpf/Pickers.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@
184184
<DatePicker
185185
Width="140"
186186
materialDesign:HintAssist.Hint="Pick Date"
187+
materialDesign:HintAssist.HelperText="Helper text"
187188
Style="{StaticResource MaterialDesignFilledDatePicker}"/>
188189
</smtx:XamlDisplay>
189190

@@ -194,6 +195,7 @@
194195
<DatePicker
195196
Width="140"
196197
materialDesign:HintAssist.Hint="Pick Date"
198+
materialDesign:HintAssist.HelperText="Helper text"
197199
Style="{StaticResource MaterialDesignOutlinedDatePicker}"/>
198200
</smtx:XamlDisplay>
199201
</StackPanel>

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@
416416
CornerRadius="{TemplateBinding wpf:TextFieldAssist.UnderlineCornerRadius}"
417417
Background="{TemplateBinding wpf:TextFieldAssist.UnderlineBrush}" />
418418
<Canvas
419+
x:Name="HelperTextWrapper"
419420
VerticalAlignment="Bottom">
420421
<TextBlock
421422
Canvas.Top="2"
@@ -535,6 +536,10 @@
535536
</Grid>
536537
</AdornerDecorator>
537538
<ControlTemplate.Triggers>
539+
<Trigger Property="wpf:TextFieldAssist.HasFilledTextField" Value="True">
540+
<Setter Property="Padding" Value="16 8 12 8" />
541+
<Setter TargetName="HelperTextWrapper" Property="Margin" Value="16 0 0 0" />
542+
</Trigger>
538543
<Trigger
539544
Property="wpf:TextFieldAssist.HasOutlinedTextField"
540545
Value="True">
@@ -606,6 +611,7 @@
606611
</MultiBinding>
607612
</Setter.Value>
608613
</Setter>
614+
<Setter TargetName="HelperTextWrapper" Property="Margin" Value="16 0 0 0" />
609615
</Trigger>
610616
<Trigger
611617
Property="IsEditable"
@@ -1360,6 +1366,7 @@
13601366
</Style>
13611367

13621368
<Style x:Key="MaterialDesignFilledComboBox" TargetType="{x:Type ComboBox}" BasedOn="{StaticResource MaterialDesignFloatingHintComboBox}">
1369+
<Setter Property="wpf:TextFieldAssist.HasFilledTextField" Value="True"/>
13631370
<Setter Property="wpf:TextFieldAssist.TextFieldCornerRadius" Value="4,4,0,0" />
13641371
<Setter Property="wpf:ComboBoxAssist.ShowSelectedItem" Value="True"/>
13651372
<Setter Property="VerticalContentAlignment" Value="Stretch" />

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DatePicker.xaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@
213213
Visibility="{TemplateBinding wpf:TextFieldAssist.DecorationVisibility}"
214214
CornerRadius="{TemplateBinding wpf:TextFieldAssist.UnderlineCornerRadius}"
215215
Background="{TemplateBinding wpf:TextFieldAssist.UnderlineBrush}" />
216-
<Canvas VerticalAlignment="Bottom">
216+
<Canvas x:Name="HelperTextWrapper" VerticalAlignment="Bottom">
217217
<TextBlock
218218
Canvas.Top="2"
219219
FontSize="{TemplateBinding wpf:HintAssist.HelperTextFontSize}"
@@ -258,14 +258,15 @@
258258
</Setter>
259259
</MultiTrigger>
260260
<Trigger Property="wpf:TextFieldAssist.HasFilledTextField" Value="True">
261-
<Setter Property="Padding" Value="16 8" />
261+
<Setter Property="Padding" Value="16 8 12 8" />
262262
<Setter Property="Background" Value="{DynamicResource MaterialDesignTextFieldBoxBackground}" />
263+
<Setter TargetName="HelperTextWrapper" Property="Margin" Value="16 0 0 0" />
263264
</Trigger>
264265
<Trigger Property="wpf:TextFieldAssist.HasOutlinedTextField" Value="True">
265266
<Setter Property="VerticalContentAlignment" Value="Top" />
266267
<Setter Property="BorderThickness" Value="1" />
267268
<Setter Property="BorderBrush" Value="{DynamicResource MaterialDesignTextAreaBorder}" />
268-
<Setter Property="Padding" Value="16" />
269+
<Setter Property="Padding" Value="16 16 12 16" />
269270
<Setter TargetName="Underline" Property="Visibility" Value="Collapsed" />
270271
<Setter TargetName="Hint" Property="HintOpacity" Value="1" />
271272
<Setter TargetName="HintWrapper" Property="Opacity"
@@ -281,6 +282,7 @@
281282
</MultiBinding>
282283
</Setter.Value>
283284
</Setter>
285+
<Setter TargetName="HelperTextWrapper" Property="Margin" Value="16 0 0 0" />
284286
</Trigger>
285287
<MultiTrigger>
286288
<MultiTrigger.Conditions>

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PasswordBox.xaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
Background="{TemplateBinding wpf:TextFieldAssist.UnderlineBrush}"
159159
CornerRadius="{TemplateBinding wpf:TextFieldAssist.UnderlineCornerRadius}"
160160
Visibility="{TemplateBinding wpf:TextFieldAssist.DecorationVisibility}" />
161-
<Canvas VerticalAlignment="Bottom">
161+
<Canvas x:Name="HelperTextWrapper" VerticalAlignment="Bottom">
162162
<TextBlock
163163
Canvas.Top="2"
164164
MaxWidth="{Binding ActualWidth, ElementName=border}"
@@ -251,15 +251,16 @@
251251
</Setter>
252252
</MultiTrigger>
253253
<Trigger Property="wpf:TextFieldAssist.HasFilledTextField" Value="True">
254-
<Setter Property="Padding" Value="16,8" />
254+
<Setter Property="Padding" Value="16 8 12 8" />
255255
<Setter Property="Background" Value="{DynamicResource MaterialDesignTextFieldBoxBackground}" />
256256
<Setter Property="wpf:TextFieldAssist.TextBoxViewMargin" Value="{x:Static wpf:Constants.DefaultTextBoxViewMarginEmbedded}" />
257+
<Setter TargetName="HelperTextWrapper" Property="Margin" Value="16 0 0 0" />
257258
</Trigger>
258259
<Trigger Property="wpf:TextFieldAssist.HasOutlinedTextField" Value="True">
259260
<Setter Property="VerticalContentAlignment" Value="Top" />
260261
<Setter Property="BorderThickness" Value="1" />
261262
<Setter Property="BorderBrush" Value="{DynamicResource MaterialDesignTextAreaBorder}" />
262-
<Setter Property="Padding" Value="16" />
263+
<Setter Property="Padding" Value="16 16 12 16" />
263264
<Setter Property="wpf:TextFieldAssist.TextBoxViewMargin" Value="{x:Static wpf:Constants.DefaultTextBoxViewMarginEmbedded}" />
264265
<Setter TargetName="Underline" Property="Visibility" Value="Collapsed" />
265266
<Setter TargetName="Hint" Property="HintOpacity" Value="1" />
@@ -275,6 +276,7 @@
275276
</MultiBinding>
276277
</Setter.Value>
277278
</Setter>
279+
<Setter TargetName="HelperTextWrapper" Property="Margin" Value="16 0 0 0" />
278280
</Trigger>
279281
<MultiTrigger>
280282
<MultiTrigger.Conditions>

0 commit comments

Comments
 (0)