MonoTouch Dialog. Buttons with the Elements API

不羁岁月 提交于 2019-12-11 00:07:12

问题


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 (); })


来源:https://stackoverflow.com/questions/7666356/monotouch-dialog-buttons-with-the-elements-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!