Wanted: example of RadMenu with icons only in TopLevel items

4 posts, 1 answers
  1. Debbie
    Debbie avatar
    15 posts
    Member since:
    Mar 2009

    Posted 07 May 2009 Link to this post

    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
  2. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 12 May 2009 Link to this post

    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.
  3. DevCraft banner
  4. Debbie
    Debbie avatar
    15 posts
    Member since:
    Mar 2009

    Posted 13 May 2009 Link to this post

    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> 
  5. Answer
    Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 13 May 2009 Link to this post

    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.
Back to Top