I am relatively new to WPF was wondering if anyone could help me out.
I have a collectionview that holds an observablecollection list that stores all my items. My datagrid's item source is the collection view. I have simple grouping in datagrid XAML...
<DataGrid.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}" FontWeight="Bold" Padding="3"/>
</StackPanel>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</DataGrid.GroupStyle>
Now... adding / removing items works just fine, however whenever I update / edit an item the groups are not updated. Let's say for example the items are grouped by city, if I have 3 items under one city name "Seattle" then change one of those city names to "Brooklyn" the "Brooklyn" city remains under the Seattle group until i repopulate the observablecollection list.
My current work around... is that whenever a city is changed I am literally clearing and repopulating my observablecollectionlist for the groups to update... There has to be a better way!
My question is, is there any way to update the datagrid group, manually / dynamically whenever i update / edit an item?
Note INotifyPropertyChanged I am 90% sure is not the problem here, I have tried all manner of combinations with this interface, the groups will not update whenever I am editing / updating items. However whenever I add an item if it is a new city, a new group would be created, if I removed all items in a city, that city group would also be removed. Also its not just specific items, its any item column.
EDIT ok, still no solution... but I found another work around, which once again is not the most elegant. I put an event handler for the city box.. so whenever the city is changed the event handler is called, and I refresh the collectionview. However the event is called whenever I add an item, called when I click on the item, and called twice whenever I make a change so it's not every efficient.. still looking for ideas.
EDIT2 I am now looking into the BeginEdit and EndEdit of IEditableObject to see if this will give me what I need
Any help is GREATLY appreciated, thank you!