You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix#31939: CommandParameter TemplateBinding lost during reparenting (#32961)
When a Button inside a ControlTemplate has both Command and CommandParameter
with TemplateBinding, the async binding application path can cause Command
to be evaluated before CommandParameter resolves, resulting in CanExecute
being called with null parameter.
## Solution
Add a BindableProperty dependency mechanism via DependsOn() method. When
CommandProperty.DependsOn(CommandParameterProperty) is registered, the
CommandElement.GetCanExecute() forces the CommandParameter binding to apply
before calling CanExecute. This ensures the parameter value is available.
## Changes
- BindableProperty: Add Dependencies property and DependsOn() method
- BindableObject: Add ForceBindingApply() to force a binding to apply immediately
- CommandElement: Force dependency bindings to apply before calling CanExecute
- ButtonElement, CheckBox, SearchBar, MenuItem, RefreshView, TextCell: Register
Command -> CommandParameter dependency
- All ICommandElement implementations: Pass CommandProperty to GetCanExecute()
## Testing
Added unit tests that verify:
1. Initial template binding works correctly
2. CommandParameter is preserved after reparenting (the bug scenario)
0 commit comments