views:

92

answers:

1

What's the best way to use WPF's built-in RoutedCommands with Caliburn?

For example, in my shell I have an Edit menu with a Copy item in it attached to the standard command found in ApplicationCommands:

<Menu>
    <MenuItem Header="Edit">
        <MenuItem Header="Copy"
                  Command="ApplicationCommands.Copy" />
    </MenuItem>
</Menu>

I want this item to be handled by a TextBox when it has the focus and by my own controls when they have the focus. In my controls I can handle Execute and CanExecute in code behind by creating a CommandBinding:

<UserControl.CommandBindings>
    <CommandBinding Command="ApplicationCommands.Copy"
                    Executed="CopyCommandExecute"
                    CanExecute="CanCopyCommandExecute" />
</UserControl.CommandBindings>

Is there a way, using Caliburn, to handle with methods in my ViewModel instead, or to redirect to another command that I expose from the ViewModel? Or am I going about this the wrong way?

A: 

I ended up creating a behaviour that allows the clipboard RoutedCommands to be redirected to other commands.

GraemeF