Category / Section
How to set ribbonbar at the right side of WPF Ribbon control?
1 min read
You can set the RibbonBar at the right side in WPF Ribbon control. Before that, you need to create a dummy RibbonBar and set the Visibility property to Hidden and then calculate the width between the RibbonBar’s and set to it.
The same has been explained in the following code example.
XAML
<Syncfusion:Ribbon SizeChanged="ribbon_SizeChanged" Name="ribbon" VerticalAlignment="Top" > <Syncfusion:RibbonTab Caption="Folder" IsChecked="True" > <Syncfusion:RibbonBar x:Name="ribbonBar1" Width="200" Header="Clean Up"> <Syncfusion:RibbonButton SizeForm="Large" SmallIcon="/Resources/Delete-All.png" Label="Delete All"/> <Syncfusion:RibbonButton SizeForm="Large" SmallIcon="/Resources/Recover-Deleted Items.png" Label="Recover Deleted Items"/> </Syncfusion:RibbonBar > <Syncfusion:RibbonBar x:Name="collapseRibbonBar" Visibility="Hidden"/> <Syncfusion:RibbonBar HorizontalAlignment="Right" Width="200" Grid.Column="2" x:Name="ribbonBar2" Header="Properties" > <Syncfusion:RibbonButton SizeForm="Large" SmallIcon="/Resources/Show-in-Favorites.png" Label="Show in Favourites"/> <Syncfusion:RibbonButton SizeForm="Large" SmallIcon="/Resources/Properties.png" Label="Folder Properties"/> <Syncfusion:RibbonButton SizeForm="Large" SmallIcon="/Resources/Archive.png" Label="Auto Archieve Settings"/> </Syncfusion:RibbonBar> </Syncfusion:RibbonTab> <Syncfusion:RibbonTab Caption="Send/Receive" IsChecked="False" /> </Syncfusion:Ribbon>
C#
private void ribbon_SizeChanged(object sender, SizeChangedEventArgs e) { RibbonTabItemsControl ribbontabitem = VisualUtils.FindDescendant(this, typeof(RibbonTabItemsControl)) as RibbonTabItemsControl; double width=0; foreach (Button item in VisualUtils.EnumChildrenOfType(ribbontabitem, typeof(Button))) { width = item.ActualWidth; } try { collapseRibbonBar.Width = ribbontabitem.ActualWidth - ((ribbonBar1.Width + ribbonBar2.Width)) - width+7; } catch(Exception ) { } }
The following screenshot displays the RibbonBar at the Right Side.