This is a migrated thread and some comments may be shown as answers.

How to specify group variants when using MVVM

3 Answers 154 Views
RibbonView and RibbonWindow
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 15 Sep 2011, 10:15 AM
Hi,

I want my buttons in the ribbon view to resize according to the available space. I can achieve what I want by specifying the three variants on the ribbon group like this:

<Telerik:RadRibbonGroup Header="Test">
    <Telerik:RadRibbonGroup.Variants>
        <Telerik:GroupVariant Priority="2" Variant="Small" />
        <Telerik:GroupVariant Priority="1" Variant="Medium" />
        <Telerik:GroupVariant Priority="0" Variant="Large" />
    </Telerik:RadRibbonGroup.Variants>
    ...
</Telerik:RadRibbonGroup>

But how can I do this when using the ribbon view in MVVM style as described in your Paint example? Here is my code:

<DataTemplate x:Name="ButtonTemplate">
    <Telerik:RadRibbonButton
        CollapseToMedium="WhenGroupIsMedium"
        CollapseToSmall="WhenGroupIsSmall"
        IsAutoSize="True"
        LargeImage="{Binding LargeIcon}"
        Size="Large"
        SmallImage="{Binding Icon}"
        Text="{Binding Caption}" />
</DataTemplate>
 
<DataTemplate x:Name="ButtonGroupTemplate">
    <Telerik:ItemsControl ItemsSource="{Binding Items}" ItemTemplate="{StaticResource ButtonTemplate}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <Telerik:RadCollapsiblePanel />
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
    </Telerik:ItemsControl>
</DataTemplate>
 
<Design:RibbonDataTemplateSelector
    x:Key="RibbonButtonDataTemplateSelector"
    Button="{StaticResource ButtonTemplate}"
    ButtonGroup="{StaticResource ButtonGroupTemplate}" />
 
<Telerik:HierarchicalDataTemplate
    x:Name="RibbonGroupTemplate"
    ItemsSource="{Binding Items}"
    ItemTemplateSelector="{StaticResource RibbonButtonDataTemplateSelector}">
    <TextBlock Text="{Binding Caption}" />
</Telerik:HierarchicalDataTemplate>
 
<Telerik:HierarchicalDataTemplate
    x:Name="RibbonTabTemplate"
    ItemsSource="{Binding Items}"
    ItemTemplate="{StaticResource RibbonGroupTemplate}">
    <TextBlock Text="{Binding Caption}" />
</Telerik:HierarchicalDataTemplate>

Where do I specify the group variants here?


Regards,
Stephan


3 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 20 Sep 2011, 02:37 PM
Hello Stephan,

Currently, you cannot bind the RibbonGroup.Variants collection. You can vote for this PITS item in order to increase its development priority. Feel free to ask if you need further info.

Greetings,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Trang
Top achievements
Rank 1
answered on 17 Apr 2012, 07:31 AM
Hello,

It looks like the PITS item has been resolved. What is the best way to specify the group variants when using MVVM?

Thanks!
0
Viktor Tsvetkov
Telerik team
answered on 19 Apr 2012, 01:33 PM
Hi Trang,

You can examine the attached sample project which shows one databound ribbon and one xaml created. If you have further questions feel free to ask.

All the best,
Viktor Tsvetkov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
RibbonView and RibbonWindow
Asked by
Marc
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Trang
Top achievements
Rank 1
Viktor Tsvetkov
Telerik team
Share this question
or