Skip to content

Commit

Permalink
Fixed keyboard focus for DatePicker control (#9340)
Browse files Browse the repository at this point in the history
* Fixed keyboard focus for DatePicker control

* Removed TabIndex and added FocusManager to set focus

* Changed calendar popup placement
  • Loading branch information
anjali-wpf authored Jul 15, 2024
1 parent cb73130 commit 5c13279
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding Border.CornerRadius}">
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<Grid FocusManager.FocusedElement="{Binding ElementName=PART_Button}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
Expand Down Expand Up @@ -135,9 +135,11 @@
Background="Transparent"
BorderBrush="Transparent"
AutomationProperties.Name="{Binding Path=(AutomationProperties.Name), Mode=OneWay, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DatePicker}}}"
Cursor="Arrow">
Cursor="Arrow"
Focusable="True"
IsTabStop="True" >
<!-- WPF overrides paddings for button -->

<TextBlock
Margin="{StaticResource DatePickerCalendarButtonPadding}"
HorizontalAlignment="Center"
Expand Down Expand Up @@ -167,7 +169,7 @@
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
AllowsTransparency="True"
Placement="Mouse"
Placement="Bottom"
PlacementTarget="{Binding ElementName=PART_TextBox}"
StaysOpen="False" />
</Grid>
Expand Down

0 comments on commit 5c13279

Please sign in to comment.