MonoTouch对话框。使用Elements API的按钮

时间:2011-10-05 19:08:59

标签: c# xamarin.ios monotouch.dialog

是否可以仅使用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);

我知道使用OnTapAttribute可以使用Reflection API,但我想知道如何使用Elements API。

当用户点击按钮时,它应该按下另一个视图控制器......

1 个答案:

答案 0 :(得分:6)

哦,我想我可以像那样使用StyledStringElement

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