MonoTouch Dialog. Buttons with the Elements API

2019-07-19 15:31发布

问题:

Is it possible to create buttons on the view using only Elements API?

var root = 
    new RootElement ("LoginScreen"){
        new Section ("Enter your credentials") {
            new EntryElement ("Username", "Your user name", "user1"),
            new EntryElement ("Password", "Your password", "", isPassword:true),
    },
    new Section () {
        new RootElement ("Login"){ 
               //Here should be a button
        }
   },
   new Section () {
        new BooleanElement ("Save your credentials", false),
   },
};

var dv = new MainController (root, true){ Autorotate = true };
navigation.PushViewController (dv, true);

I know it's possible with Reflection API using OnTapAttribute, but I wonder how to do that with Elements API.

And when user taps on the button it should Push another view controller...

回答1:

Oh I guess I can use StyledStringElement like that

new StyledStringElement ("Login", delegate{ DoLogin (); })