Good morning,
I am working on a WPF application which is using an ObservableCollection.
I have an ObservableCollection of object ( ObservableCollection data; ) which is binding with a WPF datagrid. I bind the both with thoses following instructions :
Code
ListCollectionView collection = new ListCollectionView(data);
collection.GroupDescriptions.Add(new PropertyGroupDescription("PathFile"));
datagridFile.ItemsSource = collection;It is working fine and I have on my main window a list of object sorting by "PathFile". By a contextual menu when I click on the file name on the window, I would like to reorder the files. For example put the first to the second position. I do this by using those following instructions :
Code
private int m_indexSelectedToMove;Code
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
data.Move(m_indexSelectedToMove, m_indexSelectedToMove + 1);
m_indexSelectedToMove = -1;
var itemList = (ListCollectionView)datagridFile.ItemsSource;
itemList.Refresh();
}But I noticed with debug that the command Refresh() reset the ListCollectionView and I would like to know how to do the same behavior without reset the data ?
Thank you in advance for any advice.

Ramesh MaruthiRank #937 · 2.2K reputationPosted Jul 25, 2014, 6:47 AM EDT
Romain90 reputationPosted Jul 28, 2014, 12:09 AM EDT
Ramesh MaruthiRank #937 · 2.2K reputationPosted Jul 28, 2014, 6:37 AM EDT
Romain90 reputationPosted Jul 28, 2014, 7:22 AM EDT
Ramesh MaruthiRank #937 · 2.2K reputationPosted Jul 28, 2014, 7:24 AM EDT
instead of this
u have to do itemList.Items.Refresh();
Romain90 reputationPosted Jul 28, 2014, 8:47 AM EDT
Ramesh MaruthiRank #937 · 2.2K reputationPosted Jul 28, 2014, 8:54 AM EDT