Skip to content

Commit 5994df0

Browse files
committed
fix: #1341
Use more efficient `{TemplateBinding}` for `MenuItem` templates, which also fixes the incorrect `{Binding Path}` syntax for attached properties.
1 parent c6adc9a commit 5994df0

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@
7777
<!-- TextBlock added so that screen readers don't try to read Icon -->
7878
<TextBlock Grid.Column="0"
7979
Grid.ColumnSpan="3"
80-
Width="{Binding Width, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
81-
Height="{Binding Height, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
80+
Width="{TemplateBinding Width}"
81+
Height="{TemplateBinding Height}"
8282
Margin="-10"
8383
FontSize="1"
8484
Opacity="0"
85-
Text="{Binding AutomationProperties.Name, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
85+
Text="{TemplateBinding AutomationProperties.Name}"
8686
Background="Black"/>
8787
</Grid>
8888

@@ -194,12 +194,12 @@
194194
<!-- TextBlock added so that screen readers don't try to read Icon -->
195195
<TextBlock Grid.Column="0"
196196
Grid.ColumnSpan="3"
197-
Width="{Binding Width, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
198-
Height="{Binding Height, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
197+
Width="{TemplateBinding Width}"
198+
Height="{TemplateBinding Height}"
199199
Margin="-10"
200200
FontSize="1"
201201
Opacity="0"
202-
Text="{Binding AutomationProperties.Name, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
202+
Text="{TemplateBinding AutomationProperties.Name}"
203203
Background="Black"/>
204204
</Grid>
205205
</Border>
@@ -288,12 +288,12 @@
288288
<!-- TextBlock added so that screen readers don't try to read Icon -->
289289
<TextBlock Grid.Column="0"
290290
Grid.ColumnSpan="5"
291-
Width="{Binding Width, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
292-
Height="{Binding Height, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
291+
Width="{TemplateBinding Width}"
292+
Height="{TemplateBinding Height}"
293293
Margin="-10"
294294
FontSize="1"
295295
Opacity="0"
296-
Text="{Binding AutomationProperties.Name, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
296+
Text="{TemplateBinding AutomationProperties.Name}"
297297
Background="Black"/>
298298
</Grid>
299299
</Border>
@@ -369,12 +369,12 @@
369369
<!-- Fix double narration from mousing over the button and then the associated text -->
370370
<TextBlock Grid.Column="0"
371371
Grid.ColumnSpan="3"
372-
Width="{Binding Width, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
373-
Height="{Binding Height, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
372+
Width="{TemplateBinding Width}"
373+
Height="{TemplateBinding Height}"
374374
Margin="-10"
375375
FontSize="1"
376376
Opacity="0"
377-
Text="{Binding AutomationProperties.Name, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}"
377+
Text="{TemplateBinding AutomationProperties.Name}"
378378
Background="Black"/>
379379
</Grid>
380380
</Border>

0 commit comments

Comments
 (0)