Small update to Flowers sample

This commit is contained in:
Laurent Bugnion 2015-08-31 17:35:31 +02:00
Родитель 81cf21a3a4
Коммит 0132cfe17c
2 изменённых файлов: 18 добавлений и 5 удалений

Просмотреть файл

@ -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
{