public async override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState) { string errorMessage = string.Empty; ICollection <Category> rootCategories = null; try { LoadingData = true; rootCategories = await _productCatalogRepository.GetRootCategoriesAsync(5); } catch (Exception ex) { errorMessage = string.Format(CultureInfo.CurrentCulture, _resourceLoader.GetString("GeneralServiceErrorMessage"), Environment.NewLine, ex.Message); } finally { LoadingData = false; } if (!string.IsNullOrWhiteSpace(errorMessage)) { await _alertMessageService.ShowAsync(errorMessage, _resourceLoader.GetString("ErrorServiceUnreachable")); return; } var rootCategoryViewModels = new List <CategoryViewModel>(); foreach (var rootCategory in rootCategories) { rootCategoryViewModels.Add(new CategoryViewModel(rootCategory, _navigationService)); } RootCategories = new ReadOnlyCollection <CategoryViewModel>(rootCategoryViewModels); }