Forum Xamarin Xamarin.iOS

How to manage the state of the menu items ?

pierreDurantpierreDurant USMember ✭✭
edited April 2017 in Xamarin.iOS

I want to manage the state of a menu item
Let’s take the example “macmenu” provided by Xamarin

In app delegate.cs, the method:

    partial void phrasesDate (Foundation.NSObject sender) {
        if (textEditor == null) return;
    textEditor.Text += DateTime.Now.ToString("D");

I want to add
Sender.State = NSCellStateValue.On;

But of course this doesn’t work as “sender” is an NSObject and not an NSMenuItem.

So I modify the method to

partial void phrasesDate (NSMenuItem sender) {

But in this cas, I also have to modify the appdelegate.designer.cs.
[Action ("phrasesDate:")]

partial void phrasesDate (Foundation.NSObject sender);

[Action ("phrasesDate:")]

partial void phrasesDate (NSMenuItem sender);

Question: is there no other way to do this ?
Because, it’s not recommended to modify the “appdelegate.designer.cs”…



Best Answer


Sign In or Register to comment.