Context Menu in OOB

2 posts, 0 answers
  1. Lee
    Lee avatar
    11 posts
    Member since:
    Sep 2010

    Posted 07 Jan 2013 Link to this post

    Hi, 

    I'm trying to create a Context Menu in OOB. I am using version 2012.3.1224.1050. I have been able to create the Context Menu in browser but when I'm in OOB, I'm getting an error, 'Reference is not a valid visual DependencyObject.' when I'm trying to set the Context Menu IsOpen property to True. I'm using the Context Menu in a child window. Can you please explain what I'm doing wrong?

    Example:
    Dim oContextMenu As New Telerik.Windows.Controls.RadContextMenu
    Dim lstMenuItem As New ObservableCollection(Of Telerik.Windows.Controls.RadMenuItem)

     'Add Comment
     oMenuItem = AddCommentToContextMenu()

     'Display Context Menu
      With oContextMenu
                    .ItemsSource = lstMenuItem
                    .IsOpen = True
                    .HorizontalOffset = oCurrentMousePosition.X
                    .VerticalOffset = oCurrentMousePosition.Y
                End With
  2. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 07 Jan 2013 Link to this post

    Hello Lee,

    In your code RadContextMenu is not set to any visual object, that's why you are receiving an exception. You have to use the code below to set it:
    RadContextMenu.SetContextMenu(Me.LayoutRoot, oContextMenu)
       With oContextMenu
                     .ItemsSource = lstMenuItem
                     .IsOpen = True
                     .HorizontalOffset = oCurrentMousePosition.X
                     .VerticalOffset = oCurrentMousePosition.Y
                 End With

    Hopefully this helps!

    Kind regards,
    Rosen Vladimirov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top