Skip to content

Commit

Permalink
fix: #1341: MenuItem template binding error (#1343)
Browse files Browse the repository at this point in the history
* fix: #1341

Use more efficient `{TemplateBinding}` for `MenuItem` templates, which also fixes the incorrect `{Binding Path}` syntax for attached properties.

* fix: set `StaysOpenOnClick` on screen-reader `TextBlock`

* fix: Remove unnecessary TextBlock from MenuItem template
  • Loading branch information
JohnTasler authored Feb 16, 2025
1 parent 414992f commit 3742256
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions src/Wpf.Ui/Controls/Menu/MenuItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,6 @@
ContentSource="Header"
RecognizesAccessKey="True"
TextElement.Foreground="{TemplateBinding Foreground}" />
<!-- TextBlock added so that screen readers don't try to read Icon -->
<TextBlock Grid.Column="0"
Grid.ColumnSpan="3"
Width="{Binding Width, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
Height="{Binding Height, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
Margin="-10"
FontSize="1"
Opacity="0"
Text="{Binding AutomationProperties.Name, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
Background="Black"/>
</Grid>

<Popup
Expand Down Expand Up @@ -191,16 +181,6 @@
ContentSource="Header"
RecognizesAccessKey="True"
TextElement.Foreground="{TemplateBinding Foreground}" />
<!-- TextBlock added so that screen readers don't try to read Icon -->
<TextBlock Grid.Column="0"
Grid.ColumnSpan="3"
Width="{Binding Width, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
Height="{Binding Height, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
Margin="-10"
FontSize="1"
Opacity="0"
Text="{Binding AutomationProperties.Name, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
Background="Black"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
Expand Down Expand Up @@ -284,17 +264,6 @@
FontSize="11"
Foreground="{DynamicResource TextFillColorDisabledBrush}"
Text="{TemplateBinding InputGestureText}" />

<!-- TextBlock added so that screen readers don't try to read Icon -->
<TextBlock Grid.Column="0"
Grid.ColumnSpan="5"
Width="{Binding Width, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
Height="{Binding Height, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
Margin="-10"
FontSize="1"
Opacity="0"
Text="{Binding AutomationProperties.Name, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
Background="Black"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
Expand Down Expand Up @@ -365,17 +334,6 @@
FontSize="{TemplateBinding FontSize}"
Symbol="ChevronRight20" />
</Grid>

<!-- Fix double narration from mousing over the button and then the associated text -->
<TextBlock Grid.Column="0"
Grid.ColumnSpan="3"
Width="{Binding Width, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
Height="{Binding Height, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
Margin="-10"
FontSize="1"
Opacity="0"
Text="{Binding AutomationProperties.Name, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
Background="Black"/>
</Grid>
</Border>

Expand Down

0 comments on commit 3742256

Please sign in to comment.