Custom Content
ContentTemplate and CompactContentTemplate
Each RadOfficeNavigationBarItem supports setting complex structures of elements to its ContentTemplate
and CompactContentTemplate
properties. These structures will represent the values set to its Content
and CompactContent
properties.
The CompactContent, CompactContentTemplate, and CompactContentTemplateSelector properties will be used when the
IsInCompactMode
property is set to True. To learn more about this items display mode, check the View Modes article.
Example complex ContentTemplate
Example complex CompactContentTemplate
ContentTemplateSelector and CompactContentTemplateSelector
The ContentTemplateSelector and CompactContentTemplateSelector allow you to apply different data templates based on custom logic.
For the purpose of the following example, the ContentTemplateSelector
property of the RadOfficeNavigationBarItem will be used.
The example utilizes the RadGlyph element. To learn more about it, check the RadGlyph article.
Define a sample model class that will hold the name and the glyph as string of each item.
Define a model
After that, create a view model that will contain a collection of ItemModels instances. This collection will be bound to the ItemsSource
property of the RadOfficeNavigationBar
control.
Define a view model
Next, we can define a custom DataTemplateSelector
class and override its SelectTemplate
method. In it, we will check if the GlyphString property equals "No glyph" and return different DataTemplate
depending on this check.
Define a custom DataTemplateSelector
Create an instance of the custom DataTemplateSelector class in XAML and set it to each RadOfficeNavigationBarItem element.
Instantiate the custom DataTemplateSelector in XAML
ItemContainerStyle
property of the RadOfficeNavigationBar control.