The code can be found here.
We are creating the context menu and handling right-clicks the same way as described in my earlier post. The main thing is to create a DataGrid which can tell you the row that is clicked. I found that if you inherit from DataGrid, you have access to the RowsPresenter.
1: protected const string PRESENTER_CHILD_NAME = "RowsPresenter";
2: protected DataGridRowsPresenter presenter;
3: 4: public override void OnApplyTemplate()
5: {6: base.OnApplyTemplate();
7: presenter = (DataGridRowsPresenter)GetTemplateChild(PRESENTER_CHILD_NAME); 8: }I took the row and set it as the "Tag" of the Menu Item. Now we have context.
1: public virtual List<ContextMenuItemInfo> GetContextMenuContent(System.Windows.Browser.HtmlEventArgs e)
2: {3: Point curr = new Point(e.OffsetX, e.OffsetY);
4: for (var i = 0; i < presenter.Children.Count; i++)
5: { 6: var row = (DataGridRow)presenter.Children[i];7: if (ContextMenuInterceptor.IsPointWithinBounds(curr, row))
8: {9: foreach (ContextMenuItemInfo m in ContextMenuList)
10: { 11: m.Tag = row; 12: }13: return ContextMenuList;
14: } 15: }16: return null;
17: }