I have the following ViewModel
public class MainViewModel : ViewModelBase
{
public bool Processing
{
get;
set;
}
private IEnumerable<ExternalLoginModel> _authenticationProviders;
/// <summary>
///
/// </summary>
public IEnumerable<ExternalLoginModel> AuthenticationProviders
{
get
{
return _authenticationProviders;
}
set
{
_authenticationProviders = value;
RaisePropertyChanged(() => AuthenticationProviders);
}
}
/// <summary>
///
/// </summary>
public MainViewModel(IAuthenticationService authService)
{
Processing = true;
authService.GetSupportedAuthenticationProvidersAsync().ContinueWith(authProviders => { PopulateAuthProviders(authProviders.Result); });
}
/// <summary>
///
/// </summary>
/// <param name="authProviders"></param>
private void PopulateAuthProviders(IEnumerable<ExternalLoginModel> authProviders)
{
AuthenticationProviders = authProviders;
Processing = false;
}
}
The property AuthenticationProviders is bound to a ListView. The problem is that once the AuthenticationProviders are populated through the Async method (via) the constructor the ListView does not get updated. I tried RaisePropertyChanged but then I get the error The application called an interface that was marshalled for a different thread. This makes sense as well since its actually calling from another thread. How do I fix this?