Skip to content

Commit

Permalink
TextBox
Browse files Browse the repository at this point in the history
  • Loading branch information
niels9001 committed Oct 20, 2023
1 parent 976dfc1 commit 130359f
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 84 deletions.
111 changes: 29 additions & 82 deletions src/Wpf.Ui/Controls/TextBox/TextBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,10 @@
<!-- Universal WPF UI ContextMenu -->
<Setter Property="ContextMenu" Value="{DynamicResource DefaultControlContextMenu}" />
<!-- Universal WPF UI ContextMenu -->
<Setter Property="Foreground">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource TextFillColorPrimary}" />
</Setter.Value>
</Setter>
<Setter Property="CaretBrush">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource TextFillColorPrimary}" />
</Setter.Value>
</Setter>
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource ControlFillColorDefault}" />
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" Value="{DynamicResource ControlElevationBorderBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
<Setter Property="CaretBrush" Value="{DynamicResource TextControlForeground}" />
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextControlElevationBorderBrush}" />
<Setter Property="BorderThickness" Value="{StaticResource TextBoxBorderThemeThickness}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
Expand Down Expand Up @@ -124,37 +112,25 @@
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter TargetName="AccentBorder" Property="BorderThickness" Value="0,0,0,2" />
<Setter TargetName="AccentBorder" Property="BorderBrush">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource SystemAccentColorSecondary}" />
</Setter.Value>
</Setter>
<Setter TargetName="ContentBorder" Property="Background">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource ControlFillColorInputActive}" />
</Setter.Value>
</Setter>
<Setter TargetName="AccentBorder" Property="BorderBrush" Value="{DynamicResource TextControlFocusedBorderBrush}" />
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundFocused}" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsEnabled" Value="True" />
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsFocused" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="ContentBorder" Property="Background">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource ControlFillColorSecondary}" />
</Setter.Value>
</Setter>
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundPointerOver}" />
</MultiTrigger>
<Trigger Property="IsEnabled" Value="True">
<Setter Property="Cursor" Value="IBeam" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource ControlFillColorDisabledBrush}" />
<Setter TargetName="ContentBorder" Property="BorderBrush" Value="{DynamicResource ControlStrokeColorDefaultBrush}" />
<Setter TargetName="AccentBorder" Property="BorderBrush" Value="{DynamicResource ControlStrokeColorDefaultBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorDisabledBrush}" />
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundDisabled}" />
<Setter TargetName="ContentBorder" Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushDisabled}" />
<Setter TargetName="AccentBorder" Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource TextControlForegroundDisabled}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
Expand Down Expand Up @@ -211,11 +187,8 @@
Margin="0"
Padding="1,0"
VerticalAlignment="Center"
Text="{TemplateBinding PlaceholderText}">
<TextBlock.Foreground>
<SolidColorBrush Color="{DynamicResource TextPlaceholderColor}" />
</TextBlock.Foreground>
</TextBlock>
Foreground="{DynamicResource TextControlPlaceholderForeground}"
Text="{TemplateBinding PlaceholderText}" />
</Grid>

<!-- Buttons and Icons have no padding from the main element to allow absolute positions if height is larger than the text entry zone -->
Expand All @@ -234,10 +207,8 @@
Background="Transparent"
BorderBrush="Transparent"
Command="{Binding Path=TemplateButtonCommand, RelativeSource={RelativeSource TemplatedParent}}"
Cursor="Arrow">
<controls:Button.Foreground>
<SolidColorBrush Color="{DynamicResource TextFillColorTertiary}" />
</controls:Button.Foreground>
Cursor="Arrow"
Foreground="{DynamicResource TextControlButtonForeground}">
<controls:Button.Icon>
<controls:SymbolIcon FontSize="{TemplateBinding FontSize}" Symbol="Dismiss24" />
</controls:Button.Icon>
Expand Down Expand Up @@ -293,28 +264,16 @@
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter TargetName="AccentBorder" Property="BorderThickness" Value="0,0,0,2" />
<Setter TargetName="AccentBorder" Property="BorderBrush">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource SystemAccentColorSecondary}" />
</Setter.Value>
</Setter>
<Setter TargetName="ContentBorder" Property="Background">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource ControlFillColorInputActive}" />
</Setter.Value>
</Setter>
<Setter TargetName="AccentBorder" Property="BorderBrush" Value="{DynamicResource TextControlFocusedBorderBrush}" />
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundFocused}" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsEnabled" Value="True" />
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsFocused" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="ContentBorder" Property="Background">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource ControlFillColorSecondary}" />
</Setter.Value>
</Setter>
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundPointerOver}" />
</MultiTrigger>
<Trigger Property="IsReadOnly" Value="True">
<Setter TargetName="ClearButton" Property="Visibility" Value="Collapsed" />
Expand All @@ -324,13 +283,13 @@
<Setter Property="Cursor" Value="IBeam" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource ControlFillColorDisabledBrush}" />
<Setter TargetName="ContentBorder" Property="BorderBrush" Value="{DynamicResource ControlStrokeColorDefaultBrush}" />
<Setter TargetName="AccentBorder" Property="BorderBrush" Value="{DynamicResource ControlStrokeColorDefaultBrush}" />
<Setter TargetName="ControlIconLeft" Property="TextElement.Foreground" Value="{DynamicResource TextFillColorDisabledBrush}" />
<Setter TargetName="ControlIconRight" Property="TextElement.Foreground" Value="{DynamicResource TextFillColorDisabledBrush}" />
<Setter TargetName="PlaceholderTextBox" Property="Foreground" Value="{DynamicResource TextFillColorDisabledBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorDisabledBrush}" />
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundDisabled}" />
<Setter TargetName="ContentBorder" Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushDisabled}" />
<Setter TargetName="AccentBorder" Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushDisabled}" />
<Setter TargetName="ControlIconLeft" Property="TextElement.Foreground" Value="{DynamicResource TextControlForegroundDisabled}" />
<Setter TargetName="ControlIconRight" Property="TextElement.Foreground" Value="{DynamicResource TextControlForegroundDisabled}" />
<Setter TargetName="PlaceholderTextBox" Property="Foreground" Value="{DynamicResource TextControlForegroundDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource TextControlForegroundDisabled}" />
<Setter Property="ClearButtonEnabled" Value="False" />
</Trigger>
</ControlTemplate.Triggers>
Expand Down Expand Up @@ -375,22 +334,10 @@
<!-- Universal WPF UI ContextMenu -->
<Setter Property="ContextMenu" Value="{DynamicResource DefaultControlContextMenu}" />
<!-- Universal WPF UI ContextMenu -->
<Setter Property="Foreground">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource TextFillColorPrimary}" />
</Setter.Value>
</Setter>
<Setter Property="CaretBrush">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource TextFillColorPrimary}" />
</Setter.Value>
</Setter>
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource ControlFillColorDefault}" />
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" Value="{DynamicResource ControlElevationBorderBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}"/>
<Setter Property="CaretBrush" Value="{DynamicResource TextControlForeground}"/>
<Setter Property="Background" Value="{DynamicResource TextControlBackground}"/>
<Setter Property="BorderBrush" Value="{DynamicResource TextControlElevationBorderBrush}" />
<Setter Property="BorderThickness" Value="{StaticResource TextBoxBorderThemeThickness}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
Expand Down
28 changes: 28 additions & 0 deletions src/Wpf.Ui/Resources/Theme/Dark.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,16 @@
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>

<LinearGradientBrush x:Key="TextControlElevationBorderBrush" MappingMode="Absolute" StartPoint="0,0" EndPoint="0,2">
<LinearGradientBrush.RelativeTransform>
<ScaleTransform CenterY="0.5" ScaleY="-1" />
</LinearGradientBrush.RelativeTransform>
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.5" Color="{StaticResource ControlStrongStrokeColorDefault}" />
<GradientStop Offset="1.0" Color="{StaticResource ControlStrokeColorDefault}" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>

<LinearGradientBrush x:Key="CircleElevationBorderBrush" MappingMode="RelativeToBoundingBox" StartPoint="0,0" EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.70" Color="{StaticResource ControlStrokeColorSecondary}" />
Expand Down Expand Up @@ -495,4 +505,22 @@
<SolidColorBrush x:Key="NavigationViewItemBackgroundSelectedLeftFluent" Color="{StaticResource ControlFillColorDefault}" />
<SolidColorBrush x:Key="NavigationViewItemForegroundLeftFluent" Color="{StaticResource TextFillColorSecondary}" />
<SolidColorBrush x:Key="NavigationViewItemForegroundPointerOverLeftFluent" Color="{StaticResource TextFillColorSecondary}" />


<!-- TextBox -->
<SolidColorBrush x:Key="TextControlBackground" Color="{StaticResource ControlFillColorDefault}" />
<SolidColorBrush x:Key="TextControlBackgroundPointerOver" Color="{StaticResource ControlFillColorSecondary}" />
<SolidColorBrush x:Key="TextControlBackgroundFocused" Color="{StaticResource ControlFillColorInputActive}" />
<SolidColorBrush x:Key="TextControlBackgroundDisabled" Color="{StaticResource ControlFillColorDisabled}" />

<!--<SolidColorBrush x:Key="TextControlBorderBrush" Color="{StaticResource TextControlElevationBorderBrush}" />-->
<SolidColorBrush x:Key="TextControlForeground" Color="{StaticResource TextFillColorPrimary}" />
<SolidColorBrush x:Key="TextControlForegroundDisabled" Color="{StaticResource TextFillColorDisabled}" />
<SolidColorBrush x:Key="TextControlFocusedBorderBrush" Color="{StaticResource SystemAccentColorPrimary}" />
<SolidColorBrush x:Key="TextControlBorderBrushDisabled" Color="{StaticResource ControlStrokeColorDefault}" />

<SolidColorBrush x:Key="TextControlPlaceholderForeground" Color="{StaticResource TextFillColorSecondary}" />
<SolidColorBrush x:Key="TextControlButtonForeground" Color="{StaticResource TextFillColorSecondary}" />


</ResourceDictionary>
26 changes: 24 additions & 2 deletions src/Wpf.Ui/Resources/Theme/Light.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,26 @@
<!-- Elevation border brushes -->

<LinearGradientBrush x:Key="ControlElevationBorderBrush" MappingMode="Absolute" StartPoint="0,0" EndPoint="0,3">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.33" Color="{StaticResource ControlStrokeColorSecondary}" />
<GradientStop Offset="1.0" Color="{StaticResource ControlStrokeColorDefault}" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>

<LinearGradientBrush x:Key="TextControlElevationBorderBrush" MappingMode="Absolute" StartPoint="0,0" EndPoint="0,2">
<LinearGradientBrush.RelativeTransform>
<ScaleTransform CenterY="0.5" ScaleY="-1" />
</LinearGradientBrush.RelativeTransform>
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.33" Color="{StaticResource ControlStrokeColorSecondary}" />
<GradientStop Offset="0.5" Color="{StaticResource ControlStrongStrokeColorDefault}" />
<GradientStop Offset="1.0" Color="{StaticResource ControlStrokeColorDefault}" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>

<LinearGradientBrush x:Key="CircleElevationBorderBrush" MappingMode="RelativeToBoundingBox" StartPoint="0,0" EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.50" Color="{StaticResource ControlStrokeColorDefault}" />
<GradientStop Offset="0.70" Color="{StaticResource ControlStrokeColorSecondary}" />
<GradientStop Offset="0.50" Color="{StaticResource ControlStrokeColorDefault}" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>

Expand Down Expand Up @@ -502,4 +509,19 @@
<SolidColorBrush x:Key="NavigationViewItemBackgroundSelectedLeftFluent" Color="{StaticResource ControlFillColorDefault}" />
<SolidColorBrush x:Key="NavigationViewItemForegroundLeftFluent" Color="{StaticResource TextFillColorSecondary}" />
<SolidColorBrush x:Key="NavigationViewItemForegroundPointerOverLeftFluent" Color="{StaticResource TextFillColorSecondary}" />

<!-- TextBox -->
<SolidColorBrush x:Key="TextControlBackground" Color="{StaticResource ControlFillColorDefault}" />
<SolidColorBrush x:Key="TextControlBackgroundPointerOver" Color="{StaticResource ControlFillColorSecondary}" />
<SolidColorBrush x:Key="TextControlBackgroundFocused" Color="{StaticResource ControlFillColorInputActive}" />
<SolidColorBrush x:Key="TextControlBackgroundDisabled" Color="{StaticResource ControlFillColorDisabled}" />

<!--<SolidColorBrush x:Key="TextControlBorderBrush" Color="{StaticResource TextControlElevationBorderBrush}" />-->
<SolidColorBrush x:Key="TextControlForeground" Color="{StaticResource TextFillColorPrimary}" />
<SolidColorBrush x:Key="TextControlForegroundDisabled" Color="{StaticResource TextFillColorDisabled}" />
<SolidColorBrush x:Key="TextControlFocusedBorderBrush" Color="{StaticResource SystemAccentColorPrimary}" />
<SolidColorBrush x:Key="TextControlBorderBrushDisabled" Color="{StaticResource ControlStrokeColorDefault}" />

<SolidColorBrush x:Key="TextControlPlaceholderForeground" Color="{StaticResource TextFillColorSecondary}" />
<SolidColorBrush x:Key="TextControlButtonForeground" Color="{StaticResource TextFillColorSecondary}" />
</ResourceDictionary>

0 comments on commit 130359f

Please sign in to comment.