My application is that instead of having the menu be preset, I want to define it in code behind based on where the user clicked, and then make it appear automatically, not based on a mouse event.
The way I capture the click current is
MouseRightButtonDown
= in the Xamgrid definition.
The reason why I don't want to just define the menu in advance, is that I do things like look at the contents of the cell and if it has a URL in it, I offer opening the page as one of my menu selections.
Yes, you can use the IsOpen property, and there are two commands defined in XamContextMenu that you can use to open/close the context menu. Regards,Marin
I am assuming this is the key command then.
cmMgr.ContextMenu.IsOpen = true;
And to close it
cmMgr.ContextMenu.IsOpen = false;
Hi,This sample code shows how to create and open the context menu in code behind:private void txtLog_TextChanged(object sender, TextChangedEventArgs e){ TextBox element = sender as TextBox; if(string.IsNullOrEmpty(element.Text)) return; ContextMenuManager cmMgr = ContextMenuService.GetManager(element); if(cmMgr==null) { cmMgr = new ContextMenuManager(); cmMgr.OpenMode = OpenMode.None; ContextMenuService.SetManager(element, cmMgr); cmMgr.ContextMenu = new XamContextMenu(); cmMgr.ContextMenu.Placement = PlacementMode.Center; } cmMgr.ContextMenu.ItemsSource = element.Text; cmMgr.ContextMenu.IsOpen = true;}Regards,Marin