Good morning,
I am working on a WPF application which is using an ObservableCollection.
I have an ObservableCollection of object ( ObservableCollection<FileData> data; ) which is binding with a WPF datagrid. I bind the both with thoses following instructions :
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 :
private int m_indexSelectedToMove;
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.