fix: #1341: MenuItem template binding error #1343
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use more efficient
{TemplateBinding}
forMenuItem
templates, which also fixes the incorrect{Binding Path}
syntax for attached properties.Pull request type
What is the current behavior?
Currently, at runtime when debugging, while using
MenuItem
, the following error is seen in the Output Window:Issue Number: Fixes #1341
What is the new behavior?
The binding has been corrected to use
{TemplateBinding}
instead of the{Binding}
with the path specified incorrectly for attached properties.The previous template had these bindings:
Firstly, the
{Binding Path}
syntax for attached properties would have beenPath=(Automation.Text)
, with parenthesis.Secondly, a more efficient
RelativeSource
would have been{RelativeSource TemplatedParent}
.Finally, switching to a
{TemplateBinding}
is the most efficient binding, and it uses simplerPath
syntax.The new template changes these bindings as follows:
Other information
{Binding}
withRelativeSource={RelativeSource TemplatedParent}
is only appropriate in the case when the non-typical binding properties are needed, such asMode=TwoWay
. The impliedMode
for{TemplateBinding}
is 'Mode=OneWay`.I verified that there were no other such
XAML
errors in the commit e55d7d7 from @Difegue that introduced this bug.