Best way to bind Command to IEditAction with MVVM

SyntaxEditor for Silverlight Forum

Posted 13 years ago by Andre
Version: 11.1.0112
Avatar
I am new to Silverlight, Actipro, and novice at MVVM.
I am trying to use the <shared:ToolBar /> and the <editor:SyntaxEditor />.
<shared:ToolBar ..>
<Button Command="{Binding ???}" />
</shared:ToolBar>
I'd like to replace the ??? to either some Actipro static ICommand (EditorCommands?), or to my ViewModels command.

In addition, depending on what is currently being edited, I'd like the commands to reflect the changes in Enabled state (i.e. maybe the current document doesn't support RequestIntelliPromptQuickInfoSession), but if I switch to one that does, I'd like to see the button Enabled state changed (I figure that ICommand.CanExecuteChanged would need to be raised).

I tried looking at EditorCommands, and also creating a Wrapper<T> : where T : IEditAction, but I can't get them to work. I figure that there has to be someway, because I can hit the hot-keys and it auto-magically works (I assume it calls UndoAction.Execute when I hit Ctrl-Z).

Ideally, I would have little to no code in the View codebehind, but if that is cleaner, with the appropriate level of Seperation of Concerns, then I'd be happy.

Thanks

Comments (1)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Andre,

The reason we don't show command usage in our SDI Editor demo's toolbar is that native Buttons don't support CommandTarget, which is what you need to have for them to be useful with the routed commands. So unfortunately I'm not sure if you can make them command-driven like you can with our custom shared:MenuItems.


Actipro Software Support

The latest build of this product (v18.1 build 0233) was released 4 years ago, which was after the last post in this thread.