private async void CategoryList_ItemClick(object sender, ItemClickEventArgs e) { Category c = e.ClickedItem as Category; CategorySelected = c.Id; this.ProgressRingCtrl.IsActive = true; this.SplitViewRPanel.Opacity = 0; try { products = productTable .Where(product => product.CategoryName == c.CategoryName) .ToIncrementalLoadingCollection(); ProductListingGridView.ItemsSource = products; categories = await categoryTable .Where(category => category.Id == CategorySelected) .ToCollectionAsync(); this.ProgressRingCtrl.IsActive = false; this.SplitViewRPanel.Opacity = 1; CategoryList.ItemsSource = categories; } catch (Exception ex) { this.ProgressRingCtrl.IsActive = false; this.SplitViewRPanel.Opacity = 1; await new MessageDialog(ex.Message, "Error loading items").ShowAsync(); return; } ClearSelectionFilter.Visibility = Visibility.Visible; ClearSelectionFilter.Foreground = new SolidColorBrush(Windows.UI.Colors.CornflowerBlue); SetDataTemplateFilter(); if (AdaptiveStates.CurrentState == NarrowStateView2) { if (Window.Current.Bounds.Width >= 450) { VisualStateManager.GoToState(this, "MediumState", false); } else { VisualStateManager.GoToState(this, "NarrowState", false); } } }
private async Task RefreshData() { this.ProgressRingCtrl.IsActive = true; this.SplitViewRPanel.Opacity = 0; ClearSelectionFilter.Visibility = Visibility.Collapsed; ClearSelectionFilter.Foreground = new SolidColorBrush(Windows.UI.Colors.Black); MobileServiceInvalidOperationException exception = null; string ExceptionDetail = string.Empty; try { // This code refreshes the entries in the list view by querying the TodoItems table. // The query excludes completed TodoItems products = productTable .Where(product => product.Id != null) .ToIncrementalLoadingCollection(); categories = await categoryTable .Where(category => category.Id != null) .ToCollectionAsync(); this.ProgressRingCtrl.IsActive = false; this.SplitViewRPanel.Opacity = 1; CategoryList.ItemsSource = categories; ProductListingGridView.ItemsSource = products; } catch (MobileServiceInvalidOperationException e) { ExceptionDetail = e.Message; } catch (Exception e) { ExceptionDetail = e.Message; } if (!(string.IsNullOrEmpty(ExceptionDetail))) { this.ProgressRingCtrl.IsActive = false; this.SplitViewRPanel.Opacity = 1; await new MessageDialog(ExceptionDetail, "Error loading items").ShowAsync(); } }
public async Task MobileServiceCollectionLoadMoreItemsAsyncExceptionsNotHandledByDefault() { // Get the Books table MobileServiceTableQueryMock <Book> query = new MobileServiceTableQueryMock <Book>(); query.EnumerableAsyncThrowsException = true; MobileServiceIncrementalLoadingCollection <Book, Book> collection = new MobileServiceIncrementalLoadingCollection <Book, Book>(query); Exception ex = null; try { await((ISupportIncrementalLoading)collection).LoadMoreItemsAsync(10); } catch (Exception e) { ex = e; } Assert.IsNotNull(ex); }
public async Task MobileServiceCollectionLoadMoreItemsAsyncExceptionsCanBeHandled() { // Get the Books table MobileServiceTableQueryMock<Book> query = new MobileServiceTableQueryMock<Book>(); query.EnumerableAsyncThrowsException = true; MobileServiceIncrementalLoadingCollection<Book, Book> collection = new MobileServiceIncrementalLoadingCollection<Book, Book>(query); CancellationTokenSource tokenSource = new CancellationTokenSource(); Exception ex = null; try { await ((ISupportIncrementalLoading)collection).LoadMoreItemsAsync(10); } catch (Exception e) { ex = e; } Assert.IsNotNull(ex); }