ContextMenu ItemsSource between Header and Footer Items

2 posts, 0 answers
  1. Stefan
    Stefan avatar
    1 posts
    Member since:
    Sep 2012

    Posted 12 Dec 2012 Link to this post


    is it possible to define an ItemsSource for a RadContextMenu only for a particular Part of the ContextMenu?
    My Target is to have Header and Footer Items, which are always shown up (fixed Items) and to have Contextual Items which are filled from Item behind.
    I tried it with an ItemsControl. This works so far, but if I hover one Contextual Item, the full ItemsControl is highlighted. Also the Icon is indented. Please see the attached Screenshot.

    How can I remove the wrong highlighting and the Icon Indentation?

    Thank you for your help!

    My existing Source Code is the following (see ItemsControl):
            <DataTemplate x:Key="SubItemTemplate">
                <telerik:RadMenuItem Header="{Binding DisplayName}" IsEnabled="{Binding Enabled}">
                        <Image Stretch="Fill" MinHeight="0" MinWidth="0" MaxWidth="16" MaxHeight="16" Width="Auto" Height="Auto" Source="{Binding Image}" />
        <!-- Region Add -->
        <telerik:RadMenuItem Header="Add" ItemsSource="{Binding Path=PossibleSubItems}" FontWeight="Bold" ItemTemplate="{StaticResource SubItemTemplate}">
                <Image Width="16" Height="16" Stretch="Fill" Source="/Images/add2_16.png" />
        <telerik:RadMenuItem IsSeparator="True" />
        <!-- End Region -->
        <ItemsControl ItemsSource="{Binding ContextMenuSubItems}" ItemTemplate="{StaticResource SubItemTemplate}" />
        <telerik:RadMenuItem IsSeparator="True" />
        <!-- Region Delete -->
        <telerik:RadMenuItem Header="Delete...">
                <Image Source="/Images/delete2_16.png" />
        <!-- End Region -->
        <!-- Region Rename -->
        <telerik:RadMenuItem Header="Rename" />
        <!-- End Region -->
  2. Rosen Vladimirov
    Rosen Vladimirov avatar
    640 posts

    Posted 12 Dec 2012 Link to this post

    Hello Stefan,

    There is no way to have static items and meanwhile set binding to a specific ItemsSource on the same level of RadContextMenu. With your declaration of ItemsControl in RadMenu, it is wrapped in one RadMenuItem and that's the reason why the whole control is highlighted and the icons are in incorrect place. In fact the whole ItemsControl is Header of RadMenuItem.

    I suggest you to declare your items in code behind and add them to the ItemsSource. I'm sending you a simple project where this is done.

    Hopefully this helps.

    Kind regards,
    Rosen Vladimirov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top