I'm new to the MVVM _and_ async/await, so I think I'm tying myself up in knots here.
My goal is to build a simple login page that will record the user's previous login details, so I have a LoginPage ViewModel that uses ConfigurationService to load & save values.
It works on Windows 8, but not on Windows RT, where the Username, Password & Account values are either not saved or not loaded (I can't tell which, would appreciate any insight on how to debug that too!)
I am initialising the ViewModel using [ActivationComplete]:
public async Activated()
Username = await ConfigurationService.GetValue("Username", String.Empty);
Password = await ConfigurationService.GetValue("Password", String.Empty);
Account = await ConfigurationService.GetValue("Account", String.Empty);
Then later on in the same ViewModel, I save the values:
public DelegateCommand LoginCommand
if (loginCommand = null)
loginCommand = new DelegateCommand(
x => DoLogin()
async void DoLogin()
await ConfigurationService.SetValue("Username", Username);
await ConfigurationService.SetValue("Password", Password);
await ConfigurationService.SetValue("Account", Account);
... Do some login code ...
I am very unhappy about having DoLogin and Activate marked as async, but I've only done it because I'm not sure how else to avoid the compiler warnings :)
Any guidance would be very much appreciated!