Skip to content

Commit 5c13279

Browse files
author
Anjali
authored
Fixed keyboard focus for DatePicker control (#9340)
* Fixed keyboard focus for DatePicker control * Removed TabIndex and added FocusManager to set focus * Changed calendar popup placement
1 parent cb73130 commit 5c13279

File tree

1 file changed

+6
-4
lines changed
  • src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Styles

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
BorderBrush="{TemplateBinding BorderBrush}"
105105
BorderThickness="{TemplateBinding BorderThickness}"
106106
CornerRadius="{TemplateBinding Border.CornerRadius}">
107-
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
107+
<Grid FocusManager.FocusedElement="{Binding ElementName=PART_Button}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
108108
<Grid.ColumnDefinitions>
109109
<ColumnDefinition Width="*" />
110110
<ColumnDefinition Width="Auto" />
@@ -135,9 +135,11 @@
135135
Background="Transparent"
136136
BorderBrush="Transparent"
137137
AutomationProperties.Name="{Binding Path=(AutomationProperties.Name), Mode=OneWay, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DatePicker}}}"
138-
Cursor="Arrow">
138+
Cursor="Arrow"
139+
Focusable="True"
140+
IsTabStop="True" >
139141
<!-- WPF overrides paddings for button -->
140-
142+
141143
<TextBlock
142144
Margin="{StaticResource DatePickerCalendarButtonPadding}"
143145
HorizontalAlignment="Center"
@@ -167,7 +169,7 @@
167169
HorizontalAlignment="Stretch"
168170
VerticalAlignment="Top"
169171
AllowsTransparency="True"
170-
Placement="Mouse"
172+
Placement="Bottom"
171173
PlacementTarget="{Binding ElementName=PART_TextBox}"
172174
StaysOpen="False" />
173175
</Grid>

0 commit comments

Comments
 (0)