Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
75
Force a RibbonGroup to dock to the right.
posted

Is there a good way to force one single RibbonGroup within a RibbonTab to always stay docked to the right ?

I've tried to fill up the space between the last "Productive" RibonGroup and the special RibbonGroup with an empty "spacer" Group.

But keebing its width always accurate does not seem to be to easey:

<igRibbon:XamRibbonWindow
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:igRibbon="http://infragistics.com/Ribbon"
x:Class="WpfApplication5.MainWindow"
Title="MainWindow" Height="350" Width="525"
x:Name="window">
<igRibbon:RibbonWindowContentHost x:Name="paint">
<igRibbon:RibbonWindowContentHost.StatusBar>
<StatusBar Background ="#D5DBE0" MinHeight="21" MaxHeight="24" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"/>
</igRibbon:RibbonWindowContentHost.StatusBar>
<igRibbon:RibbonWindowContentHost.Ribbon>
<igRibbon:XamRibbon x:Name= "myRibbon" IsMinimized="False" Theme="Office2013">
<igRibbon:XamRibbon.TabItemAreaToolbar>
<igRibbon:TabItemAreaToolbar TabItemAreaMinWidth="150">
<igRibbon:ButtonTool Caption="About"></igRibbon:ButtonTool>
</igRibbon:TabItemAreaToolbar>
</igRibbon:XamRibbon.TabItemAreaToolbar>
<igRibbon:RibbonTabItem Header="View" >
<igRibbon:RibbonGroup x:Name="navi" Caption="NAVIGATION" Margin="7,0,0,0">
<igRibbon:RadioButtonTool
Id="Home"
x:Name="HomeButton"
Caption="HOME"
igRibbon:RibbonGroup.MaximumSize="ImageAndTextLarge"/>
<igRibbon:RadioButtonTool
Caption="BASIC"
igRibbon:RibbonGroup.MaximumSize="ImageAndTextLarge"/>
<igRibbon:RadioButtonTool
Caption="TRANSFER"
igRibbon:RibbonGroup.MaximumSize="ImageAndTextLarge"/>
</igRibbon:RibbonGroup>
<igRibbon:RibbonGroup x:Name="spacer" Width="305"/>
<igRibbon:RibbonGroup Caption="RIGHT" Margin="7,0,0,0"/>
</igRibbon:RibbonTabItem>
<igRibbon:RibbonTabItem Header="Next">
<igRibbon:RibbonGroup x:Name="nexter" Caption="FirstGroup" Margin="7,0,0,0">
</igRibbon:RibbonGroup>
<igRibbon:RibbonGroup x:Name="second" Caption="SecondGroup" Margin="7,0,0,0">
</igRibbon:RibbonGroup>
</igRibbon:RibbonTabItem>

</igRibbon:XamRibbon>
</igRibbon:RibbonWindowContentHost.Ribbon>
</igRibbon:RibbonWindowContentHost>
</igRibbon:XamRibbonWindow>

Parents
No Data
Reply
  • 34810
    Verified Answer
    Offline posted

    Hello,

    By default, I am not aware of a way to right-align a RibbonGroup inside of a RibbonTabItem. This is because the panel that the RibbonGroups sit inside of acts much like a StackPanel. After some research, I have found a way to right align the RibbonGroups inside of a RibbonTabItem though.

    This solution involves going into the default styles for the XamRibbon, and finding an implicit data template that has a data type of RibbonGroupCollection. This is where that StackPanel-like panel gets set. Implement this data template into your project. A common directory to find the default style that contains this DataTemplate is: C:\Program Files (x86)\Infragistics\2014.2\WPF\DefaultStyles\Ribbon\RibbonGeneric.xaml.

    Inside of this data template, there is an ItemsControl that is not named. I would recommend to first give it a name, then move to the end of this data template and add a DataTrigger to the DataTemplate.Triggers collection of this data template. This data trigger's binding will use a relative source binding to target the SelectedItem property of the XamTabControl that holds the RibbonTabItems. The setter for this data trigger should target that ItemsControl that you named earlier, and target the ItemsPanel property of it. Set this property to a new ItemsPanelTemplate with only a Grid in it.

    The reason for the above trigger is because unless you want to apply the right-aligned RibbonGroup to each and every one of your RibbonTabItems, you will not want to change the default style. The reason for this is because this will allow and require you to set the position of each of the RibbonGroups in that RibbonTabItem, since the element that the groups now sit in is not a Panel, but a Grid.

    One thing to note is that you will need to also set an ItemsPanel on the Groups in the tabs that have this trigger applied to it. To get the default layout of the items, I would recommend simply using an ItemsPanelTemplate with a StackPanel with Orientation="Horizontal" in it.

    I have attached a sample application demonstrating the above, which uses the XAML you had originally provided.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer
    Infragistics Inc.
    www.infragistics.com/support

    XamRibbonTest.zip
Children