Advertisement
Guest User

Untitled

a guest
Jul 21st, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. using System;
  2. using MvvmCross.Binding.BindingContext;
  3. using MvvmCross.iOS.Views;
  4. using Colingual.Core.ViewModels;
  5.  
  6. namespace Colingual.iOS
  7. {
  8. public partial class LoginView : MvxViewController
  9. {
  10. public LoginView() : base("LoginView", null)
  11. {
  12. }
  13.  
  14. public override void ViewDidLoad()
  15. {
  16. base.ViewDidLoad();
  17. // Perform any additional setup after loading the view, typically from a nib.
  18.  
  19. var set = this.CreateBindingSet<LoginView, LoginViewModel>();
  20. set.Bind(Username).To(vm => vm.Username);
  21. set.Bind(Password).To(vm => vm.Password);
  22. set.Bind(btnLogin).To(vm => vm.MyAwesomeCommand);
  23. set.Apply();
  24. }
  25.  
  26.  
  27. public override void DidReceiveMemoryWarning()
  28. {
  29. base.DidReceiveMemoryWarning();
  30. // Release any cached data, images, etc that aren't in use.
  31. }
  32. }
  33. }
  34.  
  35. using MvvmCross.Core.ViewModels;
  36.  
  37. namespace Colingual.Core.ViewModels
  38. {
  39. public class LoginViewModel : MvxViewModel
  40. {
  41. readonly IAuthenticationService _authenticationService;
  42.  
  43. public LoginViewModel(IAuthenticationService authenticationService)
  44. {
  45. _authenticationService = authenticationService;
  46. }
  47.  
  48. string _username = string.Empty;
  49. public string Username
  50. {
  51. get { return _username; }
  52. set { SetProperty(ref _username, value); }
  53. }
  54.  
  55. string _password = string.Empty;
  56. public string Password
  57. {
  58. get { return _password; }
  59. set { SetProperty(ref _password, value); }
  60. }
  61.  
  62.  
  63.  
  64. public bool AuthenticateUser() {
  65. return true;
  66. }
  67.  
  68. MvxCommand _myAwesomeCommand;
  69.  
  70.  
  71. public IMvxCommand MyAwesomeCommand
  72. {
  73. get
  74. {
  75. DoStuff();
  76. return _myAwesomeCommand;
  77. }
  78. }
  79.  
  80. void DoStuff()
  81. {
  82. string test = string.Empty;
  83. }
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement