Skip to content

Commit d892fac

Browse files
JohnTaslerpomianowski
authored andcommitted
fix: #1341: MenuItem template binding error (#1343)
* 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
1 parent 641e1a5 commit d892fac

File tree

1 file changed

+0
-42
lines changed

1 file changed

+0
-42
lines changed

src/Wpf.Ui/Controls/Menu/MenuItem.xaml

-42
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,6 @@
7474
ContentSource="Header"
7575
RecognizesAccessKey="True"
7676
TextElement.Foreground="{TemplateBinding Foreground}" />
77-
<!-- TextBlock added so that screen readers don't try to read Icon -->
78-
<TextBlock Grid.Column="0"
79-
Grid.ColumnSpan="3"
80-
Width="{Binding Width, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
81-
Height="{Binding Height, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
82-
Margin="-10"
83-
FontSize="1"
84-
Opacity="0"
85-
Text="{Binding AutomationProperties.Name, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
86-
Background="Black"/>
8777
</Grid>
8878

8979
<Popup
@@ -191,16 +181,6 @@
191181
ContentSource="Header"
192182
RecognizesAccessKey="True"
193183
TextElement.Foreground="{TemplateBinding Foreground}" />
194-
<!-- TextBlock added so that screen readers don't try to read Icon -->
195-
<TextBlock Grid.Column="0"
196-
Grid.ColumnSpan="3"
197-
Width="{Binding Width, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
198-
Height="{Binding Height, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
199-
Margin="-10"
200-
FontSize="1"
201-
Opacity="0"
202-
Text="{Binding AutomationProperties.Name, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
203-
Background="Black"/>
204184
</Grid>
205185
</Border>
206186
<ControlTemplate.Triggers>
@@ -284,17 +264,6 @@
284264
FontSize="11"
285265
Foreground="{DynamicResource TextFillColorDisabledBrush}"
286266
Text="{TemplateBinding InputGestureText}" />
287-
288-
<!-- TextBlock added so that screen readers don't try to read Icon -->
289-
<TextBlock Grid.Column="0"
290-
Grid.ColumnSpan="5"
291-
Width="{Binding Width, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
292-
Height="{Binding Height, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
293-
Margin="-10"
294-
FontSize="1"
295-
Opacity="0"
296-
Text="{Binding AutomationProperties.Name, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
297-
Background="Black"/>
298267
</Grid>
299268
</Border>
300269
<ControlTemplate.Triggers>
@@ -365,17 +334,6 @@
365334
FontSize="{TemplateBinding FontSize}"
366335
Symbol="ChevronRight20" />
367336
</Grid>
368-
369-
<!-- Fix double narration from mousing over the button and then the associated text -->
370-
<TextBlock Grid.Column="0"
371-
Grid.ColumnSpan="3"
372-
Width="{Binding Width, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
373-
Height="{Binding Height, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
374-
Margin="-10"
375-
FontSize="1"
376-
Opacity="0"
377-
Text="{Binding AutomationProperties.Name, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
378-
Background="Black"/>
379337
</Grid>
380338
</Border>
381339

0 commit comments

Comments
 (0)