Skip to content

Commit a55b536

Browse files
github-actions[bot]siagupta0202dipeshmsft
authored
[release/9.0] Fixing scrollviewer visibility in textbox (#9785)
* fixing scrollviewer visibility in textbox * Fixed padding in TextBox --------- Co-authored-by: Sia Gupta <[email protected]> Co-authored-by: Dipesh Kumar <[email protected]>
1 parent ab82c78 commit a55b536

File tree

5 files changed

+20
-81
lines changed

5 files changed

+20
-81
lines changed

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Resources/Variables.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
<Thickness x:Key="TextControlBorderThemeThickness">1</Thickness>
3131
<Thickness x:Key="TextControlBorderThemeThicknessFocused">2</Thickness>
32-
<Thickness x:Key="TextControlThemePadding">10,8,10,7</Thickness>
32+
<Thickness x:Key="TextControlThemePadding">10,5,10,6</Thickness>
3333

3434
<system:Double x:Key="ContentControlFontSize">14</system:Double>
3535
<system:Double x:Key="TextControlThemeMinHeight">24</system:Double>

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Styles/TextBox.xaml

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,6 @@
2222
<system:Double x:Key="TextBoxClearButtonHeight">24</system:Double>
2323
<system:String x:Key="ClearGlyph">&#xE894;</system:String>
2424

25-
<Style x:Key="DefaultTextBoxScrollViewerStyle" TargetType="{x:Type ScrollViewer}">
26-
<Setter Property="Margin" Value="0" />
27-
<Setter Property="Padding" Value="0" />
28-
<Setter Property="SnapsToDevicePixels" Value="True" />
29-
<Setter Property="OverridesDefaultStyle" Value="True" />
30-
<Setter Property="Template">
31-
<Setter.Value>
32-
<ControlTemplate TargetType="{x:Type ScrollViewer}">
33-
<Grid>
34-
<ScrollContentPresenter Margin="0" CanContentScroll="{TemplateBinding CanContentScroll}" />
35-
</Grid>
36-
</ControlTemplate>
37-
</Setter.Value>
38-
</Setter>
39-
</Style>
40-
4125
<Style x:Key="DefaultTextBoxBaseStyle" TargetType="{x:Type TextBoxBase}">
4226
<!-- Universal WPF UI focus -->
4327
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
@@ -79,7 +63,7 @@
7963
BorderThickness="{TemplateBinding BorderThickness}"
8064
CornerRadius="{TemplateBinding Border.CornerRadius}">
8165
<Grid
82-
Margin="{TemplateBinding Padding}"
66+
8367
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
8468
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
8569
<ScrollViewer
@@ -89,7 +73,7 @@
8973
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
9074
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
9175
IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}"
92-
Style="{StaticResource DefaultTextBoxScrollViewerStyle}"
76+
Padding="{TemplateBinding Padding}"
9377
TextElement.Foreground="{TemplateBinding Foreground}"
9478
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" />
9579
</Grid>
@@ -152,15 +136,15 @@
152136
<ColumnDefinition Width="Auto" />
153137
</Grid.ColumnDefinitions>
154138

155-
<Grid Grid.Column="0" Margin="{TemplateBinding Padding}">
139+
<Grid Grid.Column="0">
156140
<ScrollViewer
157141
x:Name="PART_ContentHost"
158142
VerticalAlignment="Center"
159143
CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}"
160144
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
161145
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
162146
IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}"
163-
Style="{StaticResource DefaultTextBoxScrollViewerStyle}"
147+
Padding="{TemplateBinding Padding}"
164148
TextElement.Foreground="{TemplateBinding Foreground}"
165149
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" />
166150
</Grid>

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Themes/Fluent.Dark.xaml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
-->
6767
<Thickness x:Key="TextControlBorderThemeThickness">1</Thickness>
6868
<Thickness x:Key="TextControlBorderThemeThicknessFocused">2</Thickness>
69-
<Thickness x:Key="TextControlThemePadding">10,8,10,7</Thickness>
69+
<Thickness x:Key="TextControlThemePadding">10,5,10,6</Thickness>
7070
<system:Double x:Key="ContentControlFontSize">14</system:Double>
7171
<system:Double x:Key="TextControlThemeMinHeight">24</system:Double>
7272
<system:Double x:Key="TextControlThemeMinWidth">0</system:Double>
@@ -4113,21 +4113,6 @@
41134113
<Thickness x:Key="TextBoxClearButtonPadding">0,0,0,0</Thickness>
41144114
<system:Double x:Key="TextBoxClearButtonHeight">24</system:Double>
41154115
<system:String x:Key="ClearGlyph"></system:String>
4116-
<Style x:Key="DefaultTextBoxScrollViewerStyle" TargetType="{x:Type ScrollViewer}">
4117-
<Setter Property="Margin" Value="0" />
4118-
<Setter Property="Padding" Value="0" />
4119-
<Setter Property="SnapsToDevicePixels" Value="True" />
4120-
<Setter Property="OverridesDefaultStyle" Value="True" />
4121-
<Setter Property="Template">
4122-
<Setter.Value>
4123-
<ControlTemplate TargetType="{x:Type ScrollViewer}">
4124-
<Grid>
4125-
<ScrollContentPresenter Margin="0" CanContentScroll="{TemplateBinding CanContentScroll}" />
4126-
</Grid>
4127-
</ControlTemplate>
4128-
</Setter.Value>
4129-
</Setter>
4130-
</Style>
41314116
<Style x:Key="DefaultTextBoxBaseStyle" TargetType="{x:Type TextBoxBase}">
41324117
<!-- Universal WPF UI focus -->
41334118
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
@@ -4158,8 +4143,8 @@
41584143
<ControlTemplate TargetType="{x:Type TextBoxBase}">
41594144
<Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
41604145
<Border x:Name="ContentBorder" MinWidth="{TemplateBinding MinWidth}" MinHeight="{TemplateBinding MinHeight}" Padding="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding Border.CornerRadius}">
4161-
<Grid Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
4162-
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center" CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}" Style="{StaticResource DefaultTextBoxScrollViewerStyle}" TextElement.Foreground="{TemplateBinding Foreground}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" />
4146+
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
4147+
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center" CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}" Padding="{TemplateBinding Padding}" TextElement.Foreground="{TemplateBinding Foreground}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" />
41634148
</Grid>
41644149
</Border>
41654150
<!-- The Accent Border is a separate element so that changes to the border thickness do not affect the position of the element -->
@@ -4201,8 +4186,8 @@
42014186
<ColumnDefinition Width="*" />
42024187
<ColumnDefinition Width="Auto" />
42034188
</Grid.ColumnDefinitions>
4204-
<Grid Grid.Column="0" Margin="{TemplateBinding Padding}">
4205-
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center" CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}" Style="{StaticResource DefaultTextBoxScrollViewerStyle}" TextElement.Foreground="{TemplateBinding Foreground}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" />
4189+
<Grid Grid.Column="0">
4190+
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center" CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}" Padding="{TemplateBinding Padding}" TextElement.Foreground="{TemplateBinding Foreground}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" />
42064191
</Grid>
42074192
<!-- Buttons and Icons have no padding from the main element to allow absolute positions if height is larger than the text entry zone -->
42084193
<Button x:Name="ClearButton" Grid.Column="1" MinWidth="{StaticResource TextBoxClearButtonHeight}" MinHeight="{StaticResource TextBoxClearButtonHeight}" Margin="{StaticResource TextBoxClearButtonMargin}" Padding="{StaticResource TextBoxClearButtonPadding}" HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="Transparent" BorderBrush="Transparent" Command="{Binding Path=TemplateButtonCommand, RelativeSource={RelativeSource TemplatedParent}}" Cursor="Arrow" IsTabStop="False" Foreground="{DynamicResource TextControlButtonForeground}">

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Themes/Fluent.HC.xaml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
-->
6767
<Thickness x:Key="TextControlBorderThemeThickness">1</Thickness>
6868
<Thickness x:Key="TextControlBorderThemeThicknessFocused">2</Thickness>
69-
<Thickness x:Key="TextControlThemePadding">10,8,10,7</Thickness>
69+
<Thickness x:Key="TextControlThemePadding">10,5,10,6</Thickness>
7070
<system:Double x:Key="ContentControlFontSize">14</system:Double>
7171
<system:Double x:Key="TextControlThemeMinHeight">24</system:Double>
7272
<system:Double x:Key="TextControlThemeMinWidth">0</system:Double>
@@ -4085,21 +4085,6 @@
40854085
<Thickness x:Key="TextBoxClearButtonPadding">0,0,0,0</Thickness>
40864086
<system:Double x:Key="TextBoxClearButtonHeight">24</system:Double>
40874087
<system:String x:Key="ClearGlyph"></system:String>
4088-
<Style x:Key="DefaultTextBoxScrollViewerStyle" TargetType="{x:Type ScrollViewer}">
4089-
<Setter Property="Margin" Value="0" />
4090-
<Setter Property="Padding" Value="0" />
4091-
<Setter Property="SnapsToDevicePixels" Value="True" />
4092-
<Setter Property="OverridesDefaultStyle" Value="True" />
4093-
<Setter Property="Template">
4094-
<Setter.Value>
4095-
<ControlTemplate TargetType="{x:Type ScrollViewer}">
4096-
<Grid>
4097-
<ScrollContentPresenter Margin="0" CanContentScroll="{TemplateBinding CanContentScroll}" />
4098-
</Grid>
4099-
</ControlTemplate>
4100-
</Setter.Value>
4101-
</Setter>
4102-
</Style>
41034088
<Style x:Key="DefaultTextBoxBaseStyle" TargetType="{x:Type TextBoxBase}">
41044089
<!-- Universal WPF UI focus -->
41054090
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
@@ -4130,8 +4115,8 @@
41304115
<ControlTemplate TargetType="{x:Type TextBoxBase}">
41314116
<Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
41324117
<Border x:Name="ContentBorder" MinWidth="{TemplateBinding MinWidth}" MinHeight="{TemplateBinding MinHeight}" Padding="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding Border.CornerRadius}">
4133-
<Grid Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
4134-
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center" CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}" Style="{StaticResource DefaultTextBoxScrollViewerStyle}" TextElement.Foreground="{TemplateBinding Foreground}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" />
4118+
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
4119+
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center" CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}" Padding="{TemplateBinding Padding}" TextElement.Foreground="{TemplateBinding Foreground}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" />
41354120
</Grid>
41364121
</Border>
41374122
<!-- The Accent Border is a separate element so that changes to the border thickness do not affect the position of the element -->
@@ -4173,8 +4158,8 @@
41734158
<ColumnDefinition Width="*" />
41744159
<ColumnDefinition Width="Auto" />
41754160
</Grid.ColumnDefinitions>
4176-
<Grid Grid.Column="0" Margin="{TemplateBinding Padding}">
4177-
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center" CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}" Style="{StaticResource DefaultTextBoxScrollViewerStyle}" TextElement.Foreground="{TemplateBinding Foreground}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" />
4161+
<Grid Grid.Column="0">
4162+
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center" CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}" Padding="{TemplateBinding Padding}" TextElement.Foreground="{TemplateBinding Foreground}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" />
41784163
</Grid>
41794164
<!-- Buttons and Icons have no padding from the main element to allow absolute positions if height is larger than the text entry zone -->
41804165
<Button x:Name="ClearButton" Grid.Column="1" MinWidth="{StaticResource TextBoxClearButtonHeight}" MinHeight="{StaticResource TextBoxClearButtonHeight}" Margin="{StaticResource TextBoxClearButtonMargin}" Padding="{StaticResource TextBoxClearButtonPadding}" HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="Transparent" BorderBrush="Transparent" Command="{Binding Path=TemplateButtonCommand, RelativeSource={RelativeSource TemplatedParent}}" Cursor="Arrow" IsTabStop="False" Foreground="{DynamicResource TextControlButtonForeground}">

0 commit comments

Comments
 (0)