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.
4 Answers, 1 is accepted
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.
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.
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.