RibbonPage.GroupTemplate Property
Gets or sets the template used to visualize objects stored as elements in the RibbonPage.GroupsSource collection. This is a dependency property.
Namespace: DevExpress.Xpf.Ribbon
Assembly: DevExpress.Xpf.Ribbon.v24.2.dll
NuGet Package: DevExpress.Wpf.Ribbon
Declaration
Property Value
Type | Description |
---|---|
DataTemplate | A DataTemplate object that specifies the corresponding template. |
Remarks
The DataTemplate must be defined as a ContentControl with a RibbonPageGroup object as the content.
The GroupTemplate property supports the MVVM design pattern. See MVVM Support to learn more.
The example below illustrates how to implement the GroupTemplate:
<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>
<Window.Resources>
<DataTemplate x:Key="groupTemplate">
<ContentControl>
<dxr:RibbonPageGroup Caption="{Binding Name}" ItemLinksSource="{Binding Items}" ItemTemplate="{StaticResource itemTemplate}"/>
</ContentControl>
</DataTemplate>
<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>
<Window.Resources>
<DataTemplate x:Key="groupTemplate">
<ContentControl>
<dxr:RibbonPageGroup Caption="{Binding Name}" ItemLinksSource="{Binding Items}" ItemTemplate="{StaticResource itemTemplate}"/>
</ContentControl>
</DataTemplate>
</Window.Resources>
public class ViewModel {
public ViewModel() {
//...
ObservableCollection<ItemBase> items = new ObservableCollection<ItemBase>();
items.Add(new ItemBase() { Name = "Item1" });
items.Add(new ItemBase() { Name = "Item2" });
ObservableCollection<Group> groups = new ObservableCollection<Group>();
groups.Add(new Group() { Name = "Group1", Items = items });
}
}
//...
public class Group : ItemBase {
public ObservableCollection<ItemBase> Items { get; set; }
}
public class ItemBase {
public string Name { get; set; }
}
See Also