How to specify group variants when using MVVM

4 posts, 0 answers
  1. Marc
    Marc avatar
    88 posts
    Member since:
    Jul 2011

    Posted 15 Sep 2011 Link to this post

    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


  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 20 Sep 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. Trang
    Trang avatar
    11 posts
    Member since:
    Feb 2012

    Posted 17 Apr 2012 Link to this post

    Hello,

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

    Thanks!
  5. Viktor Tsvetkov
    Admin
    Viktor Tsvetkov avatar
    382 posts

    Posted 19 Apr 2012 Link to this post

    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 >>

Back to Top