Request for command binding example - command in User Control

Feb 20, 2010 at 12:16 PM

I have the following scenario:

Main window hosts UserControl instance, call it View, that contains a RichTextBox instance, call it rtb. Normally, when using MVVM, we manage all commands in the ViewModel class. However, in this particular case, I want to route the Undo command that is available from the QAT to the View so I can then delegate the call to the rtb.Undo command.

How would you suggest I map all this? I don't want to do it through the ViewModel since it would force it to know about the View. Any ideas?

Feb 20, 2010 at 1:07 PM

If I get you right, you can try something like this:

<!--Quick Access Toolbar Items-->
    <Fluent:QuickAccessMenuItem Target="{Binding ElementName=undoButton}"/>            

<Fluent:RibbonTabItem .....>
     <Fluent:RibbonGroupBox .....>
          <!--Fake button (until issue #16452 with QAT not fixed)-->
          <Fluent:Button Text="Undo" Command="ApplicationCommands.Undo" Icon="...." Text="Undo" x:Name="undoButton" Visibility="Collapsed" />