When in a NSMenuItem the action is defined in code using the c# event style the function validateMenuItem is never called, however if the action is defined with a selector validateMenuItem is called as expected.
menuItem1.Activated+= (sender, e) =>
{
};
menuItem2.Action = new ObjCRuntime.Selector("menuItem2Clicked");
[Export("menuItem2Clicked:")]
public void menuItem2Clicked(NSObject sender)
{
}
[Export("validateMenuItem:")]
public bool validateMenuItem(NSMenuItem menuItem)
{
//never called for menuItem1, only for menuItem2
}
The expected behavior is validateMenuItem to be called for both menu items but it seems that the native code can not find where is defined the validateMenuItem function when the c# style for the menu item action was used.

Hello,
I can confirm that this is indeed a bug. Looks like the class created in the delegate by the runtime does not have the validateMenuItem: selector and it is set as the target of the NSMenuItem, I will attach a minimal example of an application showing the issue.
PS: You forgot the colon in the selector. Should have been menuItem2.Action = new ObjCRuntime.Selector("menuItem2Clicked:");

I somehow want to export the action at runtime
foreach (var menuItem in ViewModel.ContextMenu)
{
var action = new ActionAttribute("lookupAction:");
action.Action = menuItem.Command.ExecuteAsync();
var nsMenuItem = new NSMenuItem(menuItem.Title, new ObjCRuntime.Selector(action.Selector), "");
but I can't. Any tips or ideas much appreciated.

Hello, this is indeed a very hard bug to fix due to the way we generate the bindings. I did point this out to the Mac OS X developers, will bring it up to them again to see if they can provide you with a nice workaround or at least confirm when will the bug be tackled.