UserDialogs loading not showing

I am trying to see the download result as follows, but it is not displayed.

View.cs

ViewModel.SelectedCommand.Execute(null);

ViewModel.cs

public ICommand SelectedCommand
{
    get
    {
       return new MvxAsyncCommand(async () =>
       {
         // the following does not show loading
          using (UserDialogs.Instance.Loading("Loading..."))
          {
             var task = await _classroomService.GetClassRoomAsync(SelectedClassroom.Id);
             ObservableCollection<ClassroomViewModel> class = new ObservableCollection<ClassroomViewModel>(task.ConvertAll(x => new ClassViewModel(x)));
          }
       });
      }
 }

Another example

public ICommand ReloadCommand
{
    get
    {
      return new MvxAsyncCommand(async () =>
      {
          await RefreshList();
       });
     }
}

// the following also does not show loading
private async Task RefreshList()
{
   using (UserDialogs.Instance.Loading("Loading..."))
   {
       var task = await _classService.GetClasses();
   }
}
0
source share
1 answer

If you use Acr.MvvmCross.Plugins.UserDialogs , you see that it is discolored, and you should use Acr.UserDialogs directly .

Verify that it is initialized as follows:

You need to register it in the App.cs of your PCL project:

Mvx.RegisterSingleton<IUserDialogs>(() => UserDialogs.Instance);

And start with the Android platform project in your main action:

UserDialogs.Init(() => Mvx.Resolve<IMvxAndroidCurrentTopActivity>().Activity)

, , , IUserDialogs ( , , , ):

private readonly IUserDialogs _dialogs;
public ProgressViewModel(IUserDialogs dialogs)
{
    this._dialogs = dialogs;
}

private async Task RefreshList()
{
   using (this._dialogs.Loading("Loading..."))
   {
       try
       {
           var task = await this._classService.GetClasses();
       }
       catch(Exception exc)
       {
           // This is done only for debugging to check if here lies the problem
           throw exc;
       }
   }
}

, , -

public ICommand MyTestCommand
{
    get
    {
       return new MvxAsyncCommand(async () =>
       {
         // the following should should Loading for 3 seconds
          using (this._dialogs.Loading("Loading..."))
          {
             await Task.Delay(TimeSpan.FromSeconds(3));
          }
       });
    }
 }

...

+1

All Articles