We are experiencing problems using the context menu in our application on some Firefox browsers. The same code seems to work fine on IE. The problem seems to exist on both Firefox v3.5.7 and v3.6. The frustrating part is the context menu works fine on like 9 out of 10 people's systems running Firefox. On the systems that have problems, the context menu will not come up for the tree node that they right mouse-clicked on. It seems the VisualTreeHelper.FindElementsInHostCoordinates() method is not using the appropriate mouse coordinates? The user needs to click approximately two rows below the tree node that they actually want to show the context menu for.
Our code works fine for me in either IE or Firefox, so it is difficult for me to troubleshoot. For the most part we use code very similar to that found in this article, Reusing and customizing a single ContextMenu on a TreeView with RadControls for Silverlight.
Interestingly enough, I do experience the same or at least a similar context menu problem using the source code, ContextMenuInTreeView2.zip
, provided in the article when using Firefox; it works fine with IE. I found that in order to make it work for me in Firefox, I had to use a general tranform by changing this code:
private T FindElementAt<T>(Point coordinates) where T : UIElement
return (T)VisualTreeHelper.FindElementsInHostCoordinates(coordinates, this)
.FirstOrDefault((element) => element is T);
T FindElementAt<T>(Point coordinates) where T : UIElement
GeneralTransform generalTransform = TreeView.TransformToVisual(Application.Current.RootVisual);
Point childToParentCoordinates = generalTransform.Transform(coordinates);
T firstOrDefault = (T)
(element) => element
With the original code, the "New Child" would be added to the wrong parent. It would add it to the parent above. Here are the steps that I performed:
1. Expand "Item 3"
2. Right mouse click on "Item 3.3"
3. Select "New Child" from the context menu
The "New Child" node gets added to "Item 3.2"; not "Item 3.3" as expected.
Furthermore, I noticed that if I bring up the context menu by clicking on the bottom portion of the "Item 3.3" tree node, the "New Child" node gets added to "Item 3.3". However, if I bring up the context menu by clicking on the middle or top portion of the "Item 3.3" tree node, the child node is added to the wrong parent.
So, I thought great, I will add the general transform code that worked in this example code to our code, but unfortunately it still doesn't seem to overcome the problem :(
Is this a known problem or is there anything else that you can suggest that I try?
We are using Telerik DLL version: 2009.3.1314.1030