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 :
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.
Ramesh MaruthiPosted Jul 28, 2014, 12:54 PM
RomainPosted Jul 28, 2014, 12:47 PM
Ramesh MaruthiPosted Jul 28, 2014, 11:24 AM
instead of this
u have to do itemList.Items.Refresh();
RomainPosted Jul 28, 2014, 11:22 AM
Ramesh MaruthiPosted Jul 28, 2014, 10:37 AM
RomainPosted Jul 28, 2014, 4:09 AM
Ramesh MaruthiPosted Jul 25, 2014, 10:47 AM