public LoginViewModel(IAppSettingsService appSettingsService, IEdsWebApiService edsWebApiService) { _appSettingsService = appSettingsService; _edsWebApiService = edsWebApiService; Email = _appSettingsService.GetSettings().Email; StorePassword = !string.IsNullOrEmpty(_appSettingsService.GetSettings().ProtectedPassword); SecurePassword = PasswordEncryptionService.UnProtectToSecureString(_appSettingsService.GetSettings().ProtectedPassword); _loginEnabled = this.WhenAnyValue( x => x.Email, x => x.SecurePassword, x => x.IsLoggedIn, (email, securePassword, isLoggedIn) => !isLoggedIn && !string.IsNullOrEmpty(email) && (securePassword.Length != 0)).ToProperty(this, x => x.LoginEnabled); LoginCommand = ReactiveCommand.CreateFromTask( async() => { await DoLogin(); }, this.WhenAnyValue(x => x.LoginEnabled)); LoginCommand.ThrownExceptions.Subscribe(ex => MessageBus.Current.SendMessage(ex)); }