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