This is a migrated thread and some comments may be shown as answers.

Wanted: example of RadMenu with icons only in TopLevel items

3 Answers 160 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Debbie
Top achievements
Rank 1
Debbie asked on 07 May 2009, 03:04 PM
Hi

I'm using a horizontally-orientated databound RadMenu with a Hierarchical datatemplate as the itemtemplate. Please can you send me a working example of a databound hierarchical RadMenu with template/styles attached so that icons only appear in the TopLevel items/headers and NOT any of the submenus.

Thanks so much!
Debbie

3 Answers, 1 is accepted

Sort by
0
Boyan
Telerik team
answered on 12 May 2009, 03:09 PM
Hello Debbie,

You should use a RootItemTemplate which sets your binding just for root items. I have attached a simple project how this is done. Take a look at it and if you still have problems I will be glad to help you resolve them.

Kind regards,
Boyan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Debbie
Top achievements
Rank 1
answered on 13 May 2009, 09:25 AM
HI Boyan

Thanks for your help - it really helped! I'm almost there, but now I need to bind the Click event to my OnClick property on my menu object. I seem to remember that you can't bind to the Click property? (it doesn't work!) How can I specify what should happen on the Click of the menuitems if I don't have access to the items themselves?

Thanks so much!
Debbie
<UserControl.Resources> 
    <DesignTimeData:MenuData x:Key="MenuDataDS" d:IsDataSource="True"/>  
    <Client:ImageConverter x:Key="imageConverter" /> 
 
    <telerik:ContainerBindingCollection x:Key="RootItemContainerBindings">  
        <telerik:ContainerBinding PropertyName="Header" Binding="{Binding Label}" /> 
        <telerik:ContainerBinding PropertyName="Icon" Binding="{Binding IconSource, Converter={StaticResource imageConverter}}" /> 
        <telerik:ContainerBinding PropertyName="IsEnabled" Binding="{Binding IsEnabled}" /> 
        <telerik:ContainerBinding PropertyName="Visibility" Binding="{Binding Visibility}" /> 
        <telerik:ContainerBinding PropertyName="Click" Binding="{Binding OnClick}" />
    </telerik:ContainerBindingCollection> 
 
    <telerik:ContainerBindingCollection x:Key="ItemContainerBindings">  
        <telerik:ContainerBinding PropertyName="Header" Binding="{Binding Label}" /> 
        <telerik:ContainerBinding PropertyName="IsEnabled" Binding="{Binding IsEnabled}" /> 
        <telerik:ContainerBinding PropertyName="Visibility" Binding="{Binding Visibility}" /> 
        <telerik:ContainerBinding PropertyName="Click" Binding="{Binding OnClick}" />
    </telerik:ContainerBindingCollection> 
 
    <telerik:HierarchicalDataTemplate x:Key="ItemTemplate" ItemsSource="{Binding Children}" telerik:ContainerBinding.ContainerBindings="{StaticResource ItemContainerBindings}" /> 
 
    <telerik:HierarchicalDataTemplate x:Key="RootItemTemplate" ItemTemplate="{StaticResource ItemTemplate}" ItemsSource="{Binding Children}" telerik:ContainerBinding.ContainerBindings="{StaticResource RootItemContainerBindings}" /> 
 
    ...styles...  
 
</UserControl.Resources> 
 
<Grid> 
    <teleriknav:RadMenu x:Name="menuFile" Orientation="Horizontal" Style="{StaticResource RadMenuTelerikContainerBindingStyle}" ItemContainerStyle="{StaticResource RadMenuItemContainerBinding}" ItemsSource="{Binding Mode=OneWay, Path=MenuItems, Source={StaticResource MenuDataDS}}" ItemTemplate="{StaticResource RootItemTemplate}"  VerticalAlignment="Top" Height="32" /> 
</Grid> 
0
Accepted
Valeri Hristov
Telerik team
answered on 13 May 2009, 10:48 AM
Hello Debbie,

You need to handle the RadMenuItem.ItemClick routed event on RadMenu to get notification when the user click an item. The following forum thread contains a sample code:
http://www.telerik.com/community/forums/silverlight/menu/radmenu-and-hierarchicaldatatemplate.aspx#722876

Please, note that you need to include the Telerik.Windows namespace to your usings in order to get the AddHandler() extension method to compile.

All the best,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Menu
Asked by
Debbie
Top achievements
Rank 1
Answers by
Boyan
Telerik team
Debbie
Top achievements
Rank 1
Valeri Hristov
Telerik team
Share this question
or