This is a migrated thread and some comments may be shown as answers.

Context Menu in OOB

1 Answer 40 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 07 Jan 2013, 06:07 AM
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

1 Answer, 1 is accepted

Sort by
0
Rosen Vladimirov
Telerik team
answered on 07 Jan 2013, 07:00 AM
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.

Tags
Menu
Asked by
Lee
Top achievements
Rank 1
Answers by
Rosen Vladimirov
Telerik team
Share this question
or