Created
May 23, 2015 23:56
-
-
Save pshomov/4b158ca0b0801809b0d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Prism.Mvvm; | |
using Xamarin.Forms; | |
using System.ComponentModel; | |
using System.Threading.Tasks; | |
namespace MVVMEasy.Pages | |
{ | |
public class LoginPageViewModel_FodyPropertyChanged_And_MVVMCommand : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
public LoginPageViewModel_FodyPropertyChanged_And_MVVMCommand () | |
{ | |
ErrorMessage = ""; | |
LoginInProgress = false; | |
Username = ""; | |
Password = ""; | |
Login = new MVVMCommand (async _ => { | |
ErrorMessage = ""; | |
LoginInProgress = true; | |
try { | |
await Task.Delay (5000); | |
} catch (Exception e) { | |
ErrorMessage = e.Message; | |
} | |
LoginInProgress = false; | |
}, _ => IsLoginEnabled); | |
} | |
public Command Login { get; set; } | |
public bool IsLoginEnabled { | |
get { return !LoginInProgress && (Username.Length > 0 && Password.Length > 0); } | |
} | |
public string ErrorMessage { get; set; } | |
public bool IsError { | |
get { return ErrorMessage != ""; } | |
} | |
public bool LoginInProgress { get; set; } | |
public bool LoginNotInProgress { get { return !LoginInProgress; } } | |
public string Username { get; set; } | |
public string Password { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment