This question is locked. New answers and comments are not allowed.
Hello guys,
I am writing a Custom Control and I use your ContextMenu. In that control I have 2 buttons. Button 1 has a ContextMenu attached. I want to show the ContextMenu under Button 1 when I click Button 2, so I created a custom event and a public method to Button 1, that looks like this:
In the .cs file of the Custom Control I handle the Click Event of Button 2:
And the declaration of the menu looks like this:
But when I click Button 2, I get this exception:
"An exception of type 'System.Security.VerificationException' occurred in DynamicTypes but was not handled in user code
Additional information: Operation could destabilize the runtime."
And it is pointing to my "ShowContextMenuEvent(sender);" line in the "OnShowContextMenu(object sender)" method.
Any idea what am I doing wrong ? It it is a bug into the ContextMenu ?
I am writing a Custom Control and I use your ContextMenu. In that control I have 2 buttons. Button 1 has a ContextMenu attached. I want to show the ContextMenu under Button 1 when I click Button 2, so I created a custom event and a public method to Button 1, that looks like this:
| public delegate void ShowContextMenuHandler(object sender); |
| public event ShowContextMenuHandler ShowContextMenuEvent; |
| protected void OnShowContextMenu(object sender) |
| { |
| if (ShowContextMenuEvent != null) |
| { |
| ShowContextMenuEvent(sender); |
| } |
| } |
| public void ShowContextMenu() |
| { |
| OnShowContextMenu(this); |
| } |
In the .cs file of the Custom Control I handle the Click Event of Button 2:
| btnMenu.Click += new RoutedEventHandler(btnMenu_Click); |
| void btnMenu_Click(object sender, RoutedEventArgs e) |
| { |
| btnMain.ShowContextMenu(); |
| } |
And the declaration of the menu looks like this:
| <my:ButtonLeft Height="30" |
| Width="91" |
| Content="Save" |
| x:Name="btnMain"> |
| <telerik:RadContextMenu.ContextMenu> |
| <telerik:RadContextMenu x:Name="DropDownContextMenu" |
| EventName="ShowContextMenuEvent" |
| Placement="Bottom"> |
| <telerik:RadMenuItem Header="Save"/> |
| <telerik:RadMenuItem Header="Save as..."/> |
| <telerik:RadMenuItem IsEnabled="False" Header="Don't Save"/> |
| </telerik:RadContextMenu> |
| </telerik:RadContextMenu.ContextMenu> |
| </my:ButtonLeft> |
But when I click Button 2, I get this exception:
"An exception of type 'System.Security.VerificationException' occurred in DynamicTypes but was not handled in user code
Additional information: Operation could destabilize the runtime."
And it is pointing to my "ShowContextMenuEvent(sender);" line in the "OnShowContextMenu(object sender)" method.
Any idea what am I doing wrong ? It it is a bug into the ContextMenu ?