RibbonPage.Commands Property
Gets or sets a RibbonPage item’s commands. You should populate this collection when you use deferred ribbon page content loading. This is a dependency property.
Namespace: DevExpress.Xpf.Ribbon
Assembly: DevExpress.Xpf.Ribbon.v24.1.dll
NuGet Package: DevExpress.Wpf.Ribbon
Declaration
Property Value
Type | Description |
---|---|
BarItemCommandCollection | A collection of RibbonPage item commands. |
Remarks
Populate the Commands collection with BarItemCommands only when you use the RibbonPage.GroupCollectionTemplate to display RibbonPage groups.
Add a command to the Commands property to make the command available even if the RibbonPage is hidden.
The following code sample is based on the previous code sample and extends its functionality with keyboard shortcut support for the New, Open, and Close buttons:
<dx:ThemedWindow ...
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
xmlns:dxr="http://schemas.devexpress.com/winfx/2008/xaml/ribbon">
<dxr:RibbonControl RibbonStyle="Office2019">
<dxr:RibbonDefaultPageCategory>
<dxr:RibbonPage Caption="File">
<!-- ... -->
</dxr:RibbonPage>
<dxr:RibbonPage Caption="Home">
<dxr:RibbonPage.Commands>
<dxb:BarItemCommand x:Key="newCommand" Command="{Binding Path=newCommand}" KeyGesture="CTRL+N" />
<dxb:BarItemCommand x:Key="openCommand" Command="{Binding Path=openCommand}" KeyGesture="CTRL+O" />
<dxb:BarItemCommand x:Key="closeCommand" Command="{Binding Path=closeCommand}" KeyGesture="CTRL+W" />
</dxr:RibbonPage.Commands>
<dxr:RibbonPage.GroupCollectionTemplate>
<DataTemplate>
<ItemsControl>
<dxr:RibbonPageGroup Caption="File">
<dxb:BarButtonItem Name="bNew" Content="New"
Command="{Binding Path=(dxr:RibbonPage.RibbonPage).Commands[newCommand], RelativeSource={RelativeSource Self}}" />
<dxb:BarButtonItem Content="Open"
Command="{Binding Path=(dxr:RibbonPage.RibbonPage).Commands[openCommand], RelativeSource={RelativeSource Self}}" />
<dxb:BarButtonItem Content="Close"
Command="{Binding Path=(dxr:RibbonPage.RibbonPage).Commands[closeCommand], RelativeSource={RelativeSource Self}}" />
<!-- ... -->
</dxr:RibbonPageGroup>
</ItemsControl>
</DataTemplate>
</dxr:RibbonPage.GroupCollectionTemplate>
</dxr:RibbonPage>
<!-- ... -->
</dxr:RibbonControl>
</dx:ThemedWindow>