2 Context Menu Icon Issues

2 posts, 0 answers
  1. Richard
    Richard avatar
    72 posts
    Member since:
    Feb 2009

    Posted 18 Sep 2011 Link to this post

    I'm having two isses with the Context Menu at the moment that I hope you can help with.. 

    Scenario 1
    A GridView with Context Menu. The Context menu has 5 items each with an ItemTemplate that is a HierarchicalDataTemplate, bound to a ViewModel and populated via a web service. 
     
    With Icons on the top level context menu items. 
    If I right click immediately after the grid as loaded I consistently get a System.Windows.Markup.XamlParseException.  If I wait a second or two after the grid has loaded I do not get this error. 
     
    Without Icons on the top level context menu items.
    If I right click immediately after the grid as loaded it works every time.
     

    <telerik:RadMenuItem Header="Add To Blueprint"
        ItemsSource="{Binding BlueprintContextMenuItems}"
        ItemTemplate="{StaticResource BlueprintContextMenuTemplate}" >
         
        <telerik:RadMenuItem.Icon>
            <Image Source="/TestApp;component/Assets/Icons/Blueprint/Blueprint_32x32.png" />
        </telerik:RadMenuItem.Icon>
    </telerik:RadMenuItem>

     
    Scenario 2
    I have a RadMenu consisting of RadMenuItems, these items are built from a HierarchicalDataTemplate. I have a context meun on some of these items with icons. The icons do not show up when the Context Menu is displayed. However, if I create a “dummy” copy of the image in xmal at the bottom of the page , ie.  <Image Source="….Img.png"  Visibility="Collapsed"/> the icons in the context menu are displayed. As if this referace to the image makes it available to the menu where as it’s own RadMenuItem.Icon does not. 
     
    Can I also just say I love these controls and the HierarchicalDataTemplate is just wonderful. :)

    Thanks,
    Richard
  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 23 Sep 2011 Link to this post

    Hello Richard,

    RadMenu/RadContextMenu indeed have this limitation which prevents their items from updating its template correctly once they are loaded. I am not sure if this is fixable at all, but should be relatively easy to workaround - you just need to set ItemsSource on the ContextMenu after it is entirely populated. I suppose this limitation is causing also the wrong loading of the Icons.

    Could you please try this approach and let us know if that fixed the issue.

    Greetings,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. DevCraft banner
Back to Top