public override async void OnNavigatedTo(INavigationParameters parameters) { try { if (parameters.ContainsKey("inventoryList")) { List <InventoryThumbnail> inventoryList = (List <InventoryThumbnail>)parameters["inventoryList"]; foreach (var inventoryThumbnail in inventoryList) { var wrappedInventory = InventoryList.FirstOrDefault(x => x.Item.inventory_id == inventoryThumbnail.inventory_id); if (wrappedInventory == null) { WrappedSelection <InventoryThumbnail> temp = new WrappedSelection <InventoryThumbnail>() { Item = inventoryThumbnail, IsSelected = false }; InventoryList.Add(temp); } else { int index = _inventoryList.IndexOf(wrappedInventory); InventoryList.Remove(wrappedInventory); InventoryList.Insert(index, new WrappedSelection <InventoryThumbnail> { Item = inventoryThumbnail, IsSelected = wrappedInventory.IsSelected }); } } AccessionCount = InventoryList.Select(i => i.Item.accession_id).Distinct().Count(); } if (parameters.ContainsKey("InventoryThumbnail")) { InventoryThumbnail inventoryThumbnail = (InventoryThumbnail)parameters["InventoryThumbnail"]; WrappedSelection <InventoryThumbnail> inventoryThumbnailItem = _inventoryList.FirstOrDefault(item => item.Item.inventory_id == inventoryThumbnail.inventory_id); if (inventoryThumbnailItem == null) { InventoryList.Add(new WrappedSelection <InventoryThumbnail> { Item = inventoryThumbnail, IsSelected = false }); } else { int index = InventoryList.IndexOf(inventoryThumbnailItem); InventoryList.Remove(inventoryThumbnailItem); InventoryList.Insert(index, new WrappedSelection <InventoryThumbnail> { Item = inventoryThumbnail, IsSelected = false }); } } if (parameters.ContainsKey("message")) { await _pageDialogService.DisplayAlertAsync("Message", (string)parameters["message"], "OK"); } } catch (Exception ex) { await _pageDialogService.DisplayAlertAsync("Error", ex.Message, "OK"); } }