Is it possible to set a CanExecute on an InteractionTrigger?
This is my code, but I know in some instances the ButtonCommand will be NULL, So I want to be sure that I do not cause any issues.
<i:Interaction.Triggers>
<i:KeyTrigger Key="Return">
<i:InvokeCommandAction Command="{TemplateBinding ButtonCommand}" />
</i:KeyTrigger>
</i:Interaction.Triggers>
Many thanks
If and when
ButtonCommand
isnull
, theCommand
property of theInvokeCommandAction
will also be set tonull
and since the implementation checks the reference before trying to invoke the command you won't get anyNullReferenceException
.So you don't have to do anything at all. This should work as expected out of the box.