views:

60

answers:

1

Is there a way to begin a storyboard wen an ICommand is executed WITH XAML?

A: 

RoutedCommands involve some code-behind, but this is definitely doable.

The simplest way is to add a CommandBinding to the parent control. Something like this:

    <UserControl>
      <UserControl.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Exit" Executed="HandleExit"/>
     </UserControl.CommandBindings>
   </UserControl>

Then in your code-behind event handler named 'HandleExit', invoke the storyboard either by name or from the Resources collection.

Let me know if you need some more clarification.

jgraves
You will also have to define an equivalent RoutedCommand or use one of the built-in RoutedCommands (ApplicationCommands, MediaCommands, etc). This solution won't work for a simple ICommand, unfortunately.
jgraves
I thought about doing it xamly, with no code involved, better said, beggining the Storyboard with Xaml when the command is hit, but I guess it's impossible.
Shimmy