
Hi,
I am currently trying to keep a memory of the last item selected when IsCategorized is enabled and disabled, because when changing between the two, everything collapse and the selection is lost.
I tried hooking on categorizedListBox.SelectionChanged (if you look at the Getting started example) and when it is triggered, I do this:
private void CategorizedListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
if (!PropertyGrid.IsCategorized)
{
//We are leaving the categorized mode, so we save the selected item in the old variable.
_oldCategorizedSelectedGridItem = SelectedGridItem;
}
else
{
//We are leaving the sorted mode, so we save the selected item in the old variable.
_oldSortedSelectedGridItem = SelectedGridItem;
}
CategorizedSelectionChanged = true;
}
The thing is that when I try to set SelectedGridItem back with one of the old saved values, it is not working. It always select the first item of the grid, even If I set IsSelected to true. I am certain that I am not setting SelectedGridItem back after, so am I even allowed to set SelectedGridItem this way? What should I do to fix this?