|
14 | 14 | <converters:MathConverter x:Key="MathMultiplyConverter" Operation="Multiply" />
|
15 | 15 | <converters:FloatingHintOffsetCalculationConverter x:Key="FloatingHintOffsetCalculationConverter" />
|
16 | 16 |
|
| 17 | + <Style x:Key="MaterialDesignCharacterCounterTextBlock" TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}"> |
| 18 | + <Setter Property="FontSize" Value="10" /> |
| 19 | + <Setter Property="VerticalAlignment" Value="Center" /> |
| 20 | + <Setter Property="Opacity" Value="0.56" /> |
| 21 | + <Setter Property="Margin" Value="0,0,16,0" /> |
| 22 | + <Setter Property="Text"> |
| 23 | + <Setter.Value> |
| 24 | + <MultiBinding StringFormat="{}{0} / {1}"> |
| 25 | + <Binding Path="Text.Length" RelativeSource="{RelativeSource FindAncestor, AncestorType=TextBoxBase}" /> |
| 26 | + <Binding Path="MaxLength" RelativeSource="{RelativeSource FindAncestor, AncestorType=TextBoxBase}" /> |
| 27 | + </MultiBinding> |
| 28 | + </Setter.Value> |
| 29 | + </Setter> |
| 30 | + </Style> |
| 31 | + |
17 | 32 | <Style x:Key="MaterialDesignTextBoxBase" TargetType="{x:Type TextBoxBase}">
|
18 | 33 | <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"/>
|
19 | 34 | <Setter Property="BorderBrush" Value="{DynamicResource MaterialDesignTextBoxBorder}" />
|
|
35 | 50 | <Setter Property="Cursor" Value="IBeam"/>
|
36 | 51 | <Setter Property="KeyboardNavigation.TabNavigation" Value="Local"/>
|
37 | 52 | <Setter Property="wpf:TextFieldAssist.IncludeSpellingSuggestions" Value="{Binding RelativeSource={RelativeSource Self}, Path=(SpellCheck.IsEnabled)}" />
|
| 53 | + <Setter Property="wpf:TextFieldAssist.CharacterCounterStyle" Value="{StaticResource MaterialDesignCharacterCounterTextBlock}" /> |
38 | 54 | <Setter Property="Template">
|
39 | 55 | <Setter.Value>
|
40 | 56 | <ControlTemplate TargetType="{x:Type TextBoxBase}">
|
|
108 | 124 |
|
109 | 125 | <Grid
|
110 | 126 | Grid.Column="1"
|
111 |
| - x:Name="grid" |
| 127 | + x:Name="grid" |
112 | 128 | MinWidth="1">
|
113 | 129 | <Grid
|
114 | 130 | Grid.Column="0">
|
|
221 | 237 | CornerRadius="{TemplateBinding wpf:TextFieldAssist.UnderlineCornerRadius}"
|
222 | 238 | Background="{TemplateBinding wpf:TextFieldAssist.UnderlineBrush}" />
|
223 | 239 | <Canvas
|
224 |
| - x:Name="HelperTextWrapper" |
225 | 240 | VerticalAlignment="Bottom">
|
226 |
| - <TextBlock |
227 |
| - Canvas.Top="2" |
228 |
| - FontSize="{TemplateBinding wpf:HintAssist.HelperTextFontSize}" |
229 |
| - MaxWidth="{Binding ActualWidth, ElementName=border}" |
230 |
| - Opacity="{TemplateBinding wpf:HintAssist.HintOpacity}" |
231 |
| - Text="{TemplateBinding wpf:HintAssist.HelperText}" /> |
| 241 | + <Grid Canvas.Top="2" |
| 242 | + x:Name="FooterGrid" |
| 243 | + Width="{Binding ActualWidth, ElementName=border}"> |
| 244 | + <Grid.ColumnDefinitions> |
| 245 | + <ColumnDefinition /> |
| 246 | + <ColumnDefinition Width="Auto"/> |
| 247 | + </Grid.ColumnDefinitions> |
| 248 | + <TextBlock |
| 249 | + x:Name="HelperTextTextBlock" |
| 250 | + FontSize="{TemplateBinding wpf:HintAssist.HelperTextFontSize}" |
| 251 | + Opacity="{TemplateBinding wpf:HintAssist.HintOpacity}" |
| 252 | + Text="{TemplateBinding wpf:HintAssist.HelperText}" /> |
| 253 | + |
| 254 | + <TextBlock |
| 255 | + Grid.Column="1" |
| 256 | + x:Name="CharacterCounterTextBlock" /> |
| 257 | + </Grid> |
232 | 258 | </Canvas>
|
233 | 259 | </Grid>
|
234 | 260 | <ControlTemplate.Triggers>
|
|
268 | 294 | <Setter Property="Padding" Value="16 8 12 8" />
|
269 | 295 | <Setter Property="Background" Value="{DynamicResource MaterialDesignTextFieldBoxBackground}" />
|
270 | 296 | <Setter Property="wpf:TextFieldAssist.TextBoxViewMargin" Value="{x:Static wpf:Constants.DefaultTextBoxViewMarginEmbedded}" />
|
271 |
| - <Setter TargetName="HelperTextWrapper" Property="Margin" Value="16 0 0 0" /> |
| 297 | + <Setter TargetName="HelperTextTextBlock" Property="Margin" Value="16 0 0 0" /> |
272 | 298 | </Trigger>
|
273 | 299 | <Trigger Property="wpf:TextFieldAssist.HasOutlinedTextField" Value="True">
|
274 | 300 | <Setter Property="VerticalContentAlignment" Value="Top" />
|
|
290 | 316 | </MultiBinding>
|
291 | 317 | </Setter.Value>
|
292 | 318 | </Setter>
|
293 |
| - <Setter TargetName="HelperTextWrapper" Property="Margin" Value="16 0 0 0" /> |
| 319 | + <Setter TargetName="HelperTextTextBlock" Property="Margin" Value="16 0 0 0" /> |
294 | 320 | </Trigger>
|
295 | 321 | <MultiTrigger>
|
296 | 322 | <MultiTrigger.Conditions>
|
|
309 | 335 | </MultiTrigger.Conditions>
|
310 | 336 | <Setter TargetName="HintWrapper" Property="Opacity" Value="1" />
|
311 | 337 | </MultiTrigger>
|
| 338 | + <DataTrigger Value="0"> |
| 339 | + <DataTrigger.Binding> |
| 340 | + <PriorityBinding> |
| 341 | + <Binding Path="MaxLength" RelativeSource="{RelativeSource Self}" FallbackValue="0" /> |
| 342 | + <Binding Source="0" /> |
| 343 | + </PriorityBinding> |
| 344 | + </DataTrigger.Binding> |
| 345 | + <Setter Property="Visibility" Value="Collapsed" TargetName="CharacterCounterTextBlock"/> |
| 346 | + </DataTrigger> |
| 347 | + <Trigger Property="Visibility" Value="Visible" SourceName="CharacterCounterTextBlock"> |
| 348 | + <Setter Property="Style" Value="{Binding Path=(wpf:TextFieldAssist.CharacterCounterStyle), RelativeSource={RelativeSource TemplatedParent}}" TargetName="CharacterCounterTextBlock"/> |
| 349 | + </Trigger> |
312 | 350 |
|
313 | 351 | <!-- IsEnabled -->
|
314 | 352 | <MultiTrigger>
|
|
429 | 467 | <Setter TargetName="border" Property="Margin" Value="-1" />
|
430 | 468 | <Setter Property="BorderThickness" Value="2" />
|
431 | 469 | <Setter Property="BorderBrush" Value="{DynamicResource MaterialDesignValidationErrorBrush}" />
|
| 470 | + <Setter Property="Margin" Value="0,0,1,0" TargetName="FooterGrid" /> |
432 | 471 | </MultiTrigger>
|
433 | 472 | </ControlTemplate.Triggers>
|
434 | 473 | </ControlTemplate>
|
|
0 commit comments