generate functionTue, 07 Feb 2023

listcollectionview groupingcolumns and calculating the amount and quantity

private void GetGroupedProducts(ObservableCollection<Product> products, ICollectionView view) { view.GroupDescriptions.Add(new PropertyGroupDescription("Category.Name")); var group = view.Groups[0]; MessageBox.Show( "The category is " + group.Name + " and there are " + group.ItemCount + " products in this category with a total value of " + group.Items.Cast<Product>().Sum(p => p.UnitPrice * p.UnitsInStock)); }

Questions about programming?Chat with your personal AI assistant