Small update to Flowers sample
This commit is contained in:
Родитель
81cf21a3a4
Коммит
0132cfe17c
|
@ -61,8 +61,11 @@ namespace Flowers.Data.ViewModel
|
|||
Flowers.Clear();
|
||||
|
||||
_isLoading = true;
|
||||
RefreshCommand.RaiseCanExecuteChanged();
|
||||
RaisePropertyChanged(() => LastLoadedFormatted);
|
||||
|
||||
Exception error = null;
|
||||
|
||||
try
|
||||
{
|
||||
var list = await _flowersService.Refresh();
|
||||
|
@ -76,14 +79,22 @@ namespace Flowers.Data.ViewModel
|
|||
LastLoaded = DateTime.Now;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = ex;
|
||||
}
|
||||
|
||||
if (error != null)
|
||||
{
|
||||
var dialog = ServiceLocator.Current.GetInstance<IDialogService>();
|
||||
dialog.ShowError(ex, "Error when refreshing", "OK", null);
|
||||
await dialog.ShowError(error, "Error when refreshing", "OK", null);
|
||||
}
|
||||
|
||||
_isLoading = false;
|
||||
RefreshCommand.RaiseCanExecuteChanged();
|
||||
RaisePropertyChanged(() => LastLoadedFormatted);
|
||||
}));
|
||||
},
|
||||
|
||||
() => !_isLoading));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,12 +125,10 @@ namespace Flowers.Data.ViewModel
|
|||
_navigationService = navigationService;
|
||||
Flowers = new ObservableCollection<FlowerViewModel>();
|
||||
|
||||
#if DEBUG
|
||||
if (IsInDesignMode)
|
||||
{
|
||||
RefreshCommand.Execute(null);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,8 +29,12 @@ namespace Flowers.Data.ViewModel
|
|||
|
||||
if (ViewModelBase.IsInDesignModeStatic)
|
||||
{
|
||||
if (!SimpleIoc.Default.IsRegistered<GalaSoft.MvvmLight.Views.INavigationService>())
|
||||
{
|
||||
SimpleIoc.Default.Register<GalaSoft.MvvmLight.Views.INavigationService, DesignNavigationService>();
|
||||
}
|
||||
|
||||
SimpleIoc.Default.Register<IFlowersService, DesignFlowersService>();
|
||||
SimpleIoc.Default.Register<GalaSoft.MvvmLight.Views.INavigationService, DesignNavigationService>();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче