private async void cbItem_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { if (cbItem.SelectedItem != null && cbItem.SelectedIndex > 0) { MyHealthCheckService.Items objItems = new MyHealthCheckService.Items(); objItems = await objWCFservice.GetQuantityAndCalorieByItemAsync(cbItem.SelectedItem.ToString()); QuantityValue.Text = objItems.QuantityValue; itemCalories = objItems.Calories; Dictionary <string, int> obj = new Dictionary <string, int>(); obj.Add(objItems.ItemValue + "," + objItems.QuantityValue, objItems.Calories); if (lstCalorieItems.IndexOf(obj) == -1) { lstCalorieItems.Add(obj); } } } catch (Exception ex) { itemCalories = 0; QuantityValue.Text = ""; } }
private async void cbCategoryItem_SelectionChanged(object sender, SelectionChangedEventArgs e) { List <MyHealthCheckService.Items> lstItems = new List <MyHealthCheckService.Items>(); lstItems = await objWCFservice.GetItemsByItemAsync(cbCategoryItem.SelectedItem.ToString()); MyHealthCheckService.Items obj = new MyHealthCheckService.Items { CategoryId = 0, ItemsId = 0, ItemValue = "Select an Item", QuantityValue = "0" }; lstItems.Insert(0, obj); cbItem.ItemsSource = lstItems.Select(l => l.ItemValue).ToList(); cbItem.SelectedIndex = 0; }