Last active
August 29, 2015 14:21
-
-
Save pshomov/eb3f85471e632bbcb9f6 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 : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
public LoginPageViewModel_FodyPropertyChanged () | |
{ | |
ErrorMessage = ""; | |
LoginInProgress = false; | |
Username = ""; | |
Password = ""; | |
Login = new Command (async _ => { | |
ErrorMessage = ""; | |
LoginInProgress = true; | |
Login.ChangeCanExecute (); | |
try { | |
// perform login | |
await Task.Delay (5000); | |
} catch (Exception e) { | |
ErrorMessage = e.Message; | |
} | |
LoginInProgress = false; | |
Login.ChangeCanExecute (); | |
}, _ => !LoginInProgress && (Username.Length > 0 && Password.Length > 0)); | |
} | |
public Command Login { get; set; } | |
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