Dynamic tabs and buttons using MVVM

Oct 7, 2009 at 4:30 AM

First and foremost I love the Ribbon control. It's an outstanding and easy control to work with.

Now to my question; can someone point me in the right direction of how to bind the ribbon control using MVVM?

I have a collection of tabs and buttons which I can load and create the ribbon dynamically when using code behind, but for the life of me can't figure out how to acheive the same things when the ribbon control is on a view and the all my handling is in the view model.

 

Thanks in advance.

Oct 7, 2009 at 9:47 PM

I've figured out how to bind a collection of groups and buttons to the RibbonTabItem, but still trying to figure out how to bind a collection of tabs.

<ribbon:RibbonTabItem Title="My Tab" ItemsSource="{Binding Source={StaticResource GroupListData}}"/>

It would be great if I could bind the tab collection, groups and buttons at runtime instead of design time though. Any thoughts?

 

Mar 12, 2010 at 3:46 PM

Hi,

I'm trying without success to bind RibbonTabItem to data and to display in an RibbonTabGroup. If I succed in doing that, I would like to bind the content of the ribbonTabGroup with RibbonButton.

 <c:RibbonTabItem Title="Import/Export" ItemsSource="{Binding Group}">
                    <c:RibbonTabItem.ItemTemplate>
                        <DataTemplate>
                            <c:RibbonGroup Title="{Binding}"/>
                        </DataTemplate>
                    </c:RibbonTabItem.ItemTemplate>   
                </c:RibbonTabItem>


Currently, i have this error ( i'm binding the itemsSource to a List<string>)

Unable to cast object of type 'System.String' to type 'Odyssey.Controls.RibbonGroup'.

Can you explain how you succeded in doing this binding ?

I thought about a solution which  consist in binding the itemsource to a List<RibbonGroup> but it will break MVVM pattern, so  i had rather to avoid that.

Thank You

Jérôme