UserDialogs加载不会弹出

时间:2018-03-09 18:32:01

标签: c# xamarin xamarin.android mvvmcross

我想知道在以下实现中我做错了什么。

我无法看到加载对话框,即使打开ClassroomViewModel也需要几秒钟。

public IMvxCommand ClassroomSelectedCommand => new MvxAsyncCommand<ClassroomViewModel>(ClassroomSelected);

private async Task ClassroomSelected(Model obj)
{
   using (UserDialogs.Instance.Loading("Loading..."))
   {
       try
       {
           ShowViewModel<ClassroomViewModel>(new { Id = obj.Id });
       }
       catch (Exception ex)
       {

       }
    }
 }

1 个答案:

答案 0 :(得分:2)

您正在使用异步API,请使用MvxAsynCommand

private IMvxAsynCommand _classroomSelectedCommand;
public IMvxAsynCommand ClassroomSelectedCommand =>  _classroomSelectedCommand ?? (_classroomSelectedCommand = new MvxAsyncCommand<ClassroomViewModel>(ClassroomSelectedAsync));

private async Task ClassroomSelectedAsync(Model obj)
{
   using (UserDialogs.Instance.Loading("Loading..."))
   {
       await Task.Delay(300);
       try
       {
           ShowViewModel<ClassroomViewModel>(new { Id = obj.Id });
       }
       catch (Exception ex)
       {

       }
    }
 }