Did none of the other XAML solutions work for you?
Do you reject the flicker that IsAsync causes?
Do you detest workarounds in C#?
Set CommandParameter
as an attribute, and Command
in a style.
For instance, instead of this:
<Button
CommandParameter="{Binding .}"
Command="{Binding Source={SOME_SOURCE}, Path=SOME_PATH}"
</Button>
Use this:
<Button
CommandParameter="{Binding .}"
<Button.Style>
<Style TargetType="Button">
<Setter Property="Command" Value="{Binding Source={SOME_SOURCE}, Path=SOME_PATH}"/>
</Style>
</Button.Style>
</Button>
I'm guessing that different types of bindings are resolved at different times, and CanExecute() is called on the bound Command
object as soon as it's resolved - even if CommandParameter
hasn't been resolved yet.
Styles use a different mechanism to set attributes. I imagine that this is resolved in a later step, meaning that CommandParameter
is guaranteed to be resolved before Command
.