// update the weapon count, refresh the datagrid, and re-sort public void Update() { indexCount = weaponlistLoader.Count(); tbWeaponCount.Text = indexCount.ToString(); dgWeaponList.Items.Refresh(); // after updating the collection, remove all SortDescription and add'em back. // this ensures the datagrid is properly updated when already sorted SortDescriptionCollection sortDescriptions = new SortDescriptionCollection(); foreach (SortDescription sd in dgWeaponList.Items.SortDescriptions) { sortDescriptions.Add(sd); } dgWeaponList.Items.SortDescriptions.Clear(); foreach (SortDescription sd in sortDescriptions) { dgWeaponList.Items.SortDescriptions.Add(sd); } // update the group by category ICollectionView view = CollectionViewSource.GetDefaultView(dgWeaponList.ItemsSource); if (view != null && view.CanGroup == true) { view.GroupDescriptions.Clear(); view.GroupDescriptions.Add(new PropertyGroupDescription("eCategory")); } }