This question is locked. New answers and comments are not allowed.
Hi,
I use the RadContentMenu Control to provide contentmenu in my application.I write my code follow the demo:
http://demos.telerik.com/silverlight/#GridView/RowContextMenu
When I run my code and click right mouse on GridView,the contentmenu is not the menu I defind,it's the default right menu of Silverlight.The content of menu is:"Silverlight(S)".
Then I use the MouseRightButtonDown Event of GridView to display RadContentMenu by Code.Follow is my event hand code:
private void GList_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
//open radcontentmenu
this.ConentMenu.IsOpen = true;
//disable default contentmenu
e.Handled = true;
}
Then I run my code and right mouse on GridView,the RadContentMenu displayed.After that,I write the Opened Event of RadContentMenu,Follow is my code:
private void ConentMenu_Opened(object sender, RoutedEventArgs e)
{
RadContextMenu menu = (RadContextMenu) sender;
//Get the selectRow
GridViewRow selectRow = menu.GetClickedElement<GridViewRow>();
if (selectRow != null)
{
//Set the selectRow as local select row
selectRow.IsSelected = true;
}
}
I run my code again,An Exception happend in the RadContentMenu Opend Event hand Code.The Expend is:Value is not within the expected range.
Follow is the detail of this Exception:
System.ArgumentException was unhandled by user code
Message=Value is not within the expected range.
StackTrace:
At MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
At MS.Internal.XcpImports.MethodPack(IntPtr objectPtr, String methodName, Object[] rawData)
At MS.Internal.XcpImports.UIElement_TransformToVisual(UIElement element, UIElement visual)
At System.Windows.UIElement.TransformToVisual(UIElement visual)
At Telerik.Windows.Controls.ApplicationHelper.TransformToScreenRoot(UIElement target)
At Telerik.Windows.Controls.VisualTreeHelperExtensions.GetElementsInHostCoordinates[T](UIElement subtree, Point position)
At Telerik.Windows.Controls.VisualTreeHelperExtensions.<>c__DisplayClass5`1.<GetElementsInScreenCoordinatesFromOpenedPopups>b__4(Popup p)
At System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
At System.Linq.Enumerable.<ConcatIterator>d__71`1.MoveNext()
At System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
At Telerik.Windows.Controls.RadContextMenu.GetClickedElement[T]()
At SSMP.SysManager.UserManager.ConentMenu_Opened(Object sender, RoutedEventArgs e)
At Telerik.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RadRoutedEventArgs routedEventArgs)
At Telerik.Windows.RouteItem.InvokeHandler(RadRoutedEventArgs routedEventArgs)
At Telerik.Windows.EventRoute.InvokeHandlersImpl(Object source, RadRoutedEventArgs args, Boolean raisedAgain)
At Telerik.Windows.EventRoute.InvokeHandlers(Object source, RadRoutedEventArgs args)
At Telerik.Windows.RadRoutedEventHelper.RaiseEvent(DependencyObject element, RadRoutedEventArgs args)
At Telerik.Windows.DependencyObjectExtensions.RaiseEvent(DependencyObject element, RadRoutedEventArgs e)
At Telerik.Windows.Controls.RadContextMenu.OnOpened(RadRoutedEventArgs e)
At Telerik.Windows.Controls.RadContextMenu.OnPopupOpened(Object source, EventArgs e)
At MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
At MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
InnerException:
I checked my code with demo,I can't find why my code get this exception.I use the VS2010 beta2 AND Silverlight4 Beta.Telerik 2010 Q1 Silverlight Control.
Could somebody help me fixed my code.Or write a simple demo for me?
Thanks very much.