I am trying to create my own ContextMenuOpening event (Event ContextMenuOpening name should be same as FrameworkElement class) when I tried to trigger that event from Xaml page its throwing “Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type” but its works fine when I hook the event in code behind.
Please find the below code Snippet to reproduce issue and provide suggestion on this.
XAML
<local:ContextMenuEvetTest x:Name="menu" ContextMenuOpening="menu_ContextMenuOpening" />
Code Behind
#region Main Class /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); //this.menu.ContextMenuOpening += menu_ContextMenuOpening; } void menu_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { } } #endregion #region Base Class public class ContextMenuEvet : Control { public ContextMenuEvet() { } public delegate void ContextMenuOpeningEventHandler(object sender, ContextMenuOpeningEventArgs e); public new event ContextMenuOpeningEventHandler ContextMenuOpening; internal void GetContextMenuOpeningEvent(ContextMenuOpeningEventArgs e) { if (ContextMenuOpening != null) ContextMenuOpening(this, e); } } #endregion #region Derived Class public class ContextMenuEvetTest : ContextMenuEvet { static ContextMenuEvetTest() { } } #endregion #region EventsArgument public class ContextMenuOpeningEventArgs : CancelEventArgs { } #endregion
Thanks in advance.
Vigneshkumar R