Skip to main content
Home Forums Silverlight Programming Report a Silverlight Bug Context Menu in Firefox
4 replies. Latest Post by mchlSync on November 4, 2009.
(0)
NemanjaM
Member
0 points
2 Posts
11-03-2009 4:45 AM |
In IE context menu is working fine, but in FF it is working on every other click.
Has anyone found solution for it?
mchlsync
Star
14606 points
2,730 Posts
11-04-2009 12:19 AM |
Can you share the code that you wrote for it? so we can try replicating this in our machine and see any solution
11-04-2009 3:47 AM |
In the constructor of the page I have added this segment of the code:
public partial class GroupsAndAreasMainPage : Telvent.SilverlightExt.MVVM.View{ public GroupsAndAreasMainPage() { InitializeComponent(); DataContext = GroupsAndAreasMainViewModel.GetInstance(); InitView(); HtmlPage.Document.AttachEvent("oncontextmenu", ((GroupsAndAreasMainViewModel)DataContext).OnContextMenu); }} In ViewModel class I have a ContextMenu method like this:
public class GroupsAndAreasMainViewModel : ViewModel { public GroupsAndAreasMainViewModel() { } public void OnContextMenu(object sender, HtmlEventArgs e) { Point clickPoint = new Point(e.OffsetX, e.OffsetY); List hittedElements = VisualTreeHelper.FindElementsInHostCoordinates(clickPoint, MainViewModel.GetInstance().LayoutRoot) as List; if (hittedElements.Count > 0) { UIElement currentElement = null; foreach (UIElement element in hittedElements) { currentElement = element; if ((element.GetType().Name == "TreeViewItem" && ((((TreeViewItem)element).GetItem() is GATreeViewItem) || (((TreeViewItem)element).GetItem() is TreeViewItem))) || (element.GetType().Name == "DataGridRow")) { break; } } PopupItems.Clear(); GeneralTransform transform = Application.Current.RootVisual.TransformToVisual(LayoutRoot); Point absolutePoint = new Point(e.OffsetX, e.OffsetY); Point relativePoint = transform.Transform(absolutePoint); if (currentElement != null) { if (currentElement.GetType().Name == "TreeViewItem") { PopupItems.Add(new PopupItem() { Name = "Add Area" }); PopupItems.Add(new PopupItem() { Name = "Edit Area" }); PopupItems.Add(new PopupItem() { Name = "Delete Area" }); GAPagePopup.HorizontalOffset = relativePoint.X; GAPagePopup.VerticalOffset = relativePoint.Y; GAPagePopup.IsOpen = true; } } } e.PreventDefault(); e.StopPropagation(); } } }
11-04-2009 7:25 AM |
Please try with contextmenu in Firefox
11-04-2009 7:56 AM |
You can also check this sample. http://www.sharpgis.net/post/2009/05/09/Adding-rightclick-to-Silverlight.aspx