gpt4 book ai didi

c# - MonoTouch.Dialog 无法获取文本字段上的值

转载 作者:行者123 更新时间:2023-11-30 21:17:08 25 4
gpt4 key购买 nike

我有以下代码

public partial class AppDelegate : UIApplicationDelegate
{
UINavigationController _navigationController = new UINavigationController();

public enum PrivacySetting { always, never, friends };

LogInViewModel _login;

// This method is invoked when the application has loaded its UI and its ready to run
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
// If you have defined a view, add it here:
// window.AddSubview (navigationController.View);

_login = new LogInViewModel
{
Privacy = PrivacySetting.always
};

var _loginbindingcontext = new BindingContext(this, _login, "Login");
var dialogcontroller = new DialogViewController(_loginbindingcontext.Root);

_navigationController.PushViewController(dialogcontroller, true);

window.AddSubview(_navigationController.View);

window.MakeKeyAndVisible ();

return true;
}

// This method is required in iPhoneOS 3.0
public override void OnActivated (UIApplication application)
{
}

public class LogInViewModel
{

[Section("Credentials")]

[Entry("Username")]
public string login;

[Caption("Password"), Password("Password")]
public string password;

[Section("Privacy")]

[Caption("Show Name")]
public PrivacySetting Privacy;

[Section ("Tap to Console")]
[OnTap ("tapme")]
public string TapMe;
}

public void tapme()
{
Console.WriteLine(_login.login);
}
}

我运行应用程序然后填写文本字段但是当我点击 TapMe 时我得到一个空值,那么我如何使用 monotouch.dialog 检索文本字段上的值?

最佳答案

您需要先在绑定(bind)上下文中调用 Fetch(),如下所示:

public void tapme()
{
_loginbindingcontext.Fetch();
Console.WriteLine(_login.login);
}

关于c# - MonoTouch.Dialog 无法获取文本字段上的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4952143/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com