Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Web Services data in ContentPage allways null from ViewModel

$
0
0

Hello all,

i have the following problem, im requesting data from my Rest service and in the ViewModel it shows everything perfekt. But when i execute the command from my ContentPage it has no data in, its allways null. I want to fill a Picker with data. The following code is from my ViewModel.

ViewModel:

public Command StartCommand {
get { return startCommand ?? (startCommand = new Command (async () => await ExecuteStartCommand ())); }
}
public async Task GetFirstLoginDetails ()
{
if (IsBusy) {
return;
}

        IsBusy = true;

        try {

            if (ConnectivityService.IsConnected ()) {
                LoginService service = new LoginService ();
                LoginModel loginModel = await service.GetLoginDetails ();
            } else {
                DialogService.ShowError ("No Internet Connection");
            }
        } catch (Exception ex) {

            Debug.WriteLine (ex);
        }

        IsBusy = false; 
    }

This ist the Code of my ContentPage. I Simply execute my Command on OnAppearing(). But Unfortunately i get null back.

protected override void OnAppearing ()
{
base.OnAppearing ();

        ViewModel.UserDetailsCommand.Execute (null);
    } 

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>