We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to use ContextTabGroups with MVVM?

I'm providing all menu content dynamically from a viewmodel, as in this example:

Now I want to add some ContextTabGroups. If I statically define these groups in XAML, I get an InvalidOperationException:

"Items collection must be empty before using ItemsSource."

Trying to turn the ContextTabGroups into a binding doesn't make things any easier. The closest I managed to get was to create a custom converter to convert my viewmodel collection to a ContextTabGroupCollection, but this results in a similar exception:

<syncfusion:Ribbon ContextTabGroups="{Binding ContextTabGroups, Converter={StaticResource ContextTabGroupConverter}}" ItemsSource="{Binding MenuTabs}" />

"Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead."

What is the correct way to achieve this? Or is databinding simply not possible with ContextTabGroups?





5 Replies

MS Mariappan S Syncfusion Team January 5, 2016 07:26 AM UTC

Hi Soon,

We would like to inform you that we don’t have this support in “Need to provide MVVM support for Ribbon's ContextTabGroup” currently and so have logged feature report regarding this. A support incident to track the status of this feature has been created under your account. Please log on to our support website to check for further updates

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents   

Please let me know if you have any questions.

Regards,
Mariappan S.


KO Konstantin October 9, 2017 11:48 AM UTC

Hi,

Was this feature implemented? If yes, could you please provide an example?



PB Priyanga Balasubramaniam Syncfusion Team October 10, 2017 08:56 AM UTC

Hi Konstantin,

Using “ContextGroupSource” and “ContextGroupContainerStyle” properties of Ribbon we can populate business object in ContextTabGroups of Ribbon. ContextTabGroup class have two properties “ItemsSource” and “ItemContainerStyle”. Using these properties, we can populate business object in RibbonTabs of each ContextTabGroup in Ribbon.

We have prepared the sample for the same.

You can find the sample from the below location.

Sample:RibbonSample_in_MVVM

Let us know if you need any other assistance on this.

Regards,
Priyanga B




KO Konstantin October 10, 2017 11:19 AM UTC

Thank you for sample.



PB Priyanga Balasubramaniam Syncfusion Team October 11, 2017 03:04 AM UTC

Hi Konstantin,

Thank you for the update.

Let us know if you need any other assistance on this.

Regards,
Priyanga B

Loader.
Up arrow icon