Style for dynamically generated RadMenuItems

3 posts, 1 answers
  1. Barry
    Barry avatar
    90 posts
    Member since:
    Jul 2011

    Posted 11 Jul 2012 Link to this post

    I have a RadMenu that I need some of the drop downs to have icons, and others to have no icons. I have made two styles, one for each, and it seems to work rather well (mostly) for static menu items, but I have some items that are generated dynamically and I can't figure out how to set the "no-icon" style on those items.

    By "no-icon" I mean no icon column at all. Below is the code for the sub items that I need to set the style on. The only thing that I can think of is that the generated ones have an icon column because they are sub menu items and I believe if they had children themselves they wouldn't have an icon column. If that's the case, what is the best way to make the styles so I can control which ones have an icon column?

    <telerik:RadMenuItem FontSize="10.667"
                  Style="{StaticResource RadMenuItemStyle}"
                  ItemsSource="{Binding Path=Projects}">
            <i:EventTrigger EventName="Click">
                <i:InvokeCommandAction Command="{Binding RadMenuItemClickCommand}"
                               CommandParameter="{Binding Path=Projects}"/>
                        <telerik:ContainerBinding PropertyName="IsCurrent"
                                          Binding="{Binding Selected, Mode=TwoWay}"/>                                       
                <TextBlock Text="{Binding Path=Name}" Foreground="Black" />
  2. Barry
    Barry avatar
    90 posts
    Member since:
    Jul 2011

    Posted 11 Jul 2012 Link to this post

    I put color backgrounds on everything in the styles and learned the difference between top level headers and items and sub level headers and items. So I added the style to the dynamic items by itemcontainerstyle.

    I guess I just didn't know what was a header and what was an item and when.
  3. Answer
    Todor avatar
    168 posts

    Posted 12 Jul 2012 Link to this post

    Hi Barry,

    Please find attached a sample project illustrating our suggested approach for customizing the RadMenuItems and meanwhile if you have more questions about RadMenuItem styling you can check this article.

    Hope that helps.

    Kind regards,
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Back to Top