ContextMenu.ItemClick event and Tag issue

5 posts, 1 answers
  1. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 29 Mar 2010 Link to this post

    Hello,

    I'm programmably creating menu items within the context menu.  I assign one a Tag property, but the MenuItem in the event argument that comes back in the ItemClick event has a null Tag, so I'm not sure why that is the case?  The tag is set in the collection of items in the menu....

    Thanks.
  2. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 30 Mar 2010 Link to this post

    Hi Brian Mains,

    We are unable to reproduce this issue.
    Could you send us sample project that reproduce it?

    Greetings,
    Hristo
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 01 Apr 2010 Link to this post

    Hey,

    I have a RadGrid, which defines a context menu:

    <

     

    tel:RadGridView x:Name="DataViewer" AutoGenerateColumns="True"

     

     

     

     

     

     

    IsFilteringAllowed="True" VerticalContentAlignment="Stretch">

     

     

     

     

    <nav:RadContextMenu.ContextMenu>

     

    <

     

    nav:RadContextMenu Opened="RadContextMenu_Opened" ItemClick="RadContextMenu_ItemClick">

     

    </

     

    nav:RadContextMenu>

     

     

     

     

     

     

     

     

    </nav:RadContextMenu.ContextMenu>

     

     

     

     

     

     

     

     

    </tel:RadGridView>

     

     


    I programmably create the UI like:

    private

     

    void ShowSingleHeaderColumnContextMenu(RadContextMenu menu)

     

    {

    menu.Items.Clear();

    menu.Items.Add(

     

    new MenuItem { Header = "A" Tag = new ATask() });

     

    menu.Items.Add(

     

    new MenuItem { Header = "B", Tag = new BTask() });

     

    }

     


    I do see these iems in the list.  And I expect that when I process the item click, the tag would be there, but this is null:

    private

     

    void RadContextMenu_ItemClick(object sender, RadRoutedEventArgs e)

     

    {

     

     

    RadContextMenu menu = e.Source as RadContextMenu;

     

     

     

    RadMenuItem clickedItem = e.OriginalSource as RadMenuItem;

     

     

     

    BaseTask task = clickedItem.Tag as BaseTask;  //common base class

     

     

     

    if (task == null)

     

     

     

    return;

     

     


    This is always true; it's always null...  but the item in the list is not.

    Also, I notice that the context menu doesn't go away; do I have to manually close it?

    Thanks.

     

     

     

  5. Answer
    Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 01 Apr 2010 Link to this post

    Hello Brian Mains,

    You are adding MenuItem (which is Microsoft control). Instead you should add RadMenuItems to get the desired behavior (Tag not null and Close context menu on ItemClick).

    Let us know if you need more help.

    Greetings,
    Hristo
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 03 Apr 2010 Link to this post

    Doh.  Thanks.
Back to Top
UI for WPF is Visual Studio 2017 Ready