MVVM???

Oct 2, 2009 at 9:51 AM

Ribbon is absolutely amazing, but what about using MVVM pattern? How can I use RibbonCommand functionality inside the ViewModel when the only way to set RibbonApplicationMenuItem LabelTitle in XAML is declaring a new RibbonCommand and not using Binding?

The only way I found to use RibbonApplicationMenuItem in XAMl is this:

<r:RibbonApplicationMenuItem>
                        <r:RibbonApplicationMenuItem.Command>
                            <r:RibbonCommand LabelTitle="LabelTitle"
                                             LabelDescription="LabelDescription"
                                             ToolTipDescription="ToolTipDescription"
                                             ToolTipFooterDescription="ToolTipFooterDescription"
                                             ToolTipFooterTitle="ToolTipFooterTitle"
                                             ToolTipTitle="ToolTipTitle" 
                                             
                                             Executed="CloseCommand_Execute"
                                             CanExecute="CloseCommand_CanExecute" />
                        </r:RibbonApplicationMenuItem.Command>
                    </r:RibbonApplicationMenuItem>

but in this way "Executed" and "CanExecuted" methods must be in the code-behind. If, instead, I use something like this <r:RibbonApplicationMenuItem Command="{Binding Path=CloseCommand}"  /> I can use my "CloseCommand" property inside the ViewModel but I can not set LabelTitle in the XAML but only in the ViewModel.  In my opinion it is not MVVM "style", because LableTitle (and the other properties) should be set inside XAML, and Command funcionality (eg Execute, CanExecute) must be inside the ViewModel and not inside the codebehind of the window hosting Ribbon.

Am I missing something or this is the way to use RibbonCommand? If I can i suggest you an improvement, it will be really appreciated if you could let us do this operations, thus respecting MVVM paradigm.

I want to apologize for my horrible english, but I'm an Italian Developer.

Best regards,

Enrico