I have the following code
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);
}
}
i run the application then i fill in the textfields but when i tap on TapMe i get a null value, so how can i retrieve values on textfields using monotouch.dialog?
You need to first call Fetch() on the binding context, like this: