RadMenu is an advanced control providing full Expression Blend support. From within the visual environment of Expression Blend, you can easily perform various tasks such as editing control properties, modifying themes, creating and modifying templates and more.
This tutorial will walk you through the creation of a RadMenu and will show you how to:
Before reading this tutorial you should get familiar with the Visual Structure of the standard RadMenu control.
For the purpose of this tutorial, you will need to create an empty WPF Application project and open it in Expression Blend.
In order to use RadMenu control in your projects you have to add references to the following assemblies:
Open the Asset Library (Window->Assets) in Expression Blend and start writing the name of the RadMenu in the search box.
Drag a RadMenu on the artboard.
<UserControl xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"> <Grid x:Name="LayoutRoot"> <telerik:RadMenu VerticalAlignment="Top" /> </Grid> </UserControl>
The class that represents the menu item is Telerik.Windows.Controls.RadMenuItem.
Select your control in Expression Blend. In the Properties Pane, find and edit the Items property.
The "Object Collection Editor" dialog will open.
Add two items of type RadMenuItem.
Set their Header properties respective to Item 1 and Item 2.
These items can have child items on their own. To add items to one of them, select it in the 'Objects and Timeline' pane.
Repeat the same steps as by the RadMenu.
Here is a snapshot of the result and the respective XAML code, generated by Expression Blend.
<telerik:RadMenu VerticalAlignment="Top"> <telerik:RadMenuItem Header="Item 1"> <telerik:RadMenuItem Header="SubItem 1" /> <telerik:RadMenuItem Header="SubItem 2" /> </telerik:RadMenuItem> <telerik:RadMenuItem Header="Item 2" /> </telerik:RadMenu>
The scenario described in the previous sections shows the usage of static items. To learn more about these type of scenarios read here.
However, in most of the cases you have to bind your RadMenu to a collection of business objects. Check out the following topics which describe in details how to work with dynamic data.
Data Binding Support Overview - describes the various data sources for the RadMenu and shows you many tips and tricks. Read this topics in order to achieve basic knowledge about how the binding mechanism works at the RadMenu.
Binding to Dynamic Data - shows you how to bind the RadMenu to a collection of business objects.
Template and Styles Selectors - describes the possibilities to adjust the appearance of the RadMenu's items depending on the data they hold.
Take a look at the Styles and Templates section which is entirely dedicated to styling and templating the RadMenu control.
In order to learn how to use the RadMenu and what capabilities it holds, read the various topics that describe its features.
The controls from our suite support different themes. You can see how to apply a theme different than the default one in the Setting a Theme help article.
Changing the theme using implicit styles will affect all controls that have styles defined in the merged resource dictionaries. This is applicable only for the controls in the scope in which the resources are merged.
To change the theme, you can follow the steps below:
Choose between the themes and add reference to the corresponding theme assembly (ex: Telerik.Windows.Themes.Windows8.dll). You can see the different themes applied in the Theming examples from our WPF Controls Examples application.
Merge the ResourceDictionaries with the namespace required for the controls that you are using from the theme assembly. For the RadMenu, you will need to merge the following resources:
Example 3 demonstrates how to merge the ResourceDictionaries so that they are applied globally for the entire application.
Example 3: Merge the ResourceDictionaries
<Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/System.Windows.xaml"/> <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.xaml"/> <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Navigation.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources>
Alternatively, you can use the theme of the control via the StyleManager.
Figure 1 shows a RadMenu with the Windows8 theme applied.
Figure 1: RadMenu with the Windows8 theme