fix(ui): text and password boxes pad their text once; shared password error state
- The text box hands its Padding to the content host itself; the template no longer adds it again, so typed text starts where the placeholder does (12 px, 8 px after a leading icon). Same for the password box. - ui:Field.Error marks an input without a validating binding (a password box) with the error border and makes the sentence its help text; the Uploader and the login dialog use it instead of drawing their own. - The brand mark keeps its orientation by itself; the local left-to-right settings are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
8 files changed
+52
-30
No files matched your search
@@ -223,24 +223,26 @@
|
||||
<Setter Property="SelectionOpacity" Value="0.35" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<!-- The text box hands its Padding to the content host itself, so the template applies it nowhere else: the
|
||||
placeholder takes it as its own padding (plus the 2 px the text view adds) and the leading icon sits at its
|
||||
left edge; with an icon, text and placeholder start 8 px after it. -->
|
||||
<ControlTemplate TargetType="TextBox">
|
||||
<Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{StaticResource Radius.Control}" SnapsToDevicePixels="True">
|
||||
<Grid Margin="{TemplateBinding Padding}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:Icon x:Name="Glyph" Glyph="{TemplateBinding ui:Field.Glyph}" Foreground="{DynamicResource Brush.TextFaint}" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<TextBlock x:Name="Placeholder" Grid.Column="1" Text="{TemplateBinding ui:Field.Placeholder}" Foreground="{DynamicResource Brush.TextFaint}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Visibility="Collapsed" IsHitTestVisible="False" TextTrimming="CharacterEllipsis" Margin="2,0,0,0" />
|
||||
<ScrollViewer x:Name="PART_ContentHost" Grid.Column="1" Focusable="False" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
<Grid>
|
||||
<ui:Icon x:Name="Glyph" Glyph="{TemplateBinding ui:Field.Glyph}" Foreground="{DynamicResource Brush.TextFaint}" HorizontalAlignment="Left"
|
||||
Margin="{TemplateBinding Padding}" />
|
||||
<TextBlock x:Name="Placeholder" Text="{TemplateBinding ui:Field.Placeholder}" Foreground="{DynamicResource Brush.TextFaint}" Padding="{TemplateBinding Padding}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Visibility="Collapsed" IsHitTestVisible="False" TextTrimming="CharacterEllipsis" Margin="24,0,0,0" />
|
||||
<ScrollViewer x:Name="PART_ContentHost" Focusable="False" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="22,0,0,0"
|
||||
HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="ui:Field.Glyph" Value="{x:Null}">
|
||||
<Setter TargetName="Glyph" Property="Visibility" Value="Collapsed" />
|
||||
<Setter TargetName="Placeholder" Property="Margin" Value="2,0,0,0" />
|
||||
<Setter TargetName="PART_ContentHost" Property="Margin" Value="0" />
|
||||
</Trigger>
|
||||
<Trigger Property="Text" Value="">
|
||||
<Setter TargetName="Placeholder" Property="Visibility" Value="Visible" />
|
||||
@@ -282,10 +284,11 @@
|
||||
<Setter Property="SelectionBrush" Value="{DynamicResource Brush.Accent}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<!-- As for TextBox, the password box hands its Padding to the content host itself. -->
|
||||
<ControlTemplate TargetType="PasswordBox">
|
||||
<Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{StaticResource Radius.Control}" SnapsToDevicePixels="True">
|
||||
<ScrollViewer x:Name="PART_ContentHost" Margin="{TemplateBinding Padding}" VerticalAlignment="Center" Focusable="False"
|
||||
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center" Focusable="False"
|
||||
HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
@@ -295,6 +298,11 @@
|
||||
<Trigger Property="IsKeyboardFocused" Value="True">
|
||||
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource Brush.Accent}" />
|
||||
</Trigger>
|
||||
<!-- A password has no binding to validate: the owner sets ui:Field.Error (DESIGN §4 error state, as TextBox). -->
|
||||
<Trigger Property="ui:Field.HasError" Value="True">
|
||||
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource Brush.Error}" />
|
||||
<Setter Property="AutomationProperties.HelpText" Value="{Binding (ui:Field.Error), RelativeSource={RelativeSource Self}}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Opacity" Value="0.4" />
|
||||
</Trigger>
|
||||
|
||||
Reference in new issue
Block a user