How to Maintain Copy of SortDescriptionCollection After DataGrid Rebind
-
Hi all, I'm using a DataGrid from the WPFToolkit v3.5 and I'm trying to reapply a user-defined sort following a refresh of the DataGrid. To do this, I'm trying to store the DataGrid's
SortDescriptionCollection
in a local variable and then re-add the SortDescriptions once the DataGrid has been rebound. My problem is that the local variable seems to be more of a pointer to thedtg.Items.SortDescriptions
collection rather than a copy and is reset back to zero once the DataGrid is rebound. Here's the code:1. Dim complexSortDesc = Me.dtgComplexQueue.Items.SortDescriptions
2. Dim numComplex As Integer = PopulateComplex().Count
3. ApplyCustomSort(dtgComplexQueue, complexSortDesc)
4. UpdateQueueTitle(numComplex)When line #1 is completed, I have a count of 2 SortDescription objects in
complexSortDesc
. After line #2 has run,complexSortDesc
has a count of zero. Here's the PopulateComplex fn:Private Function PopulateComplex() As Requests
Dim complexRequests = New Requests(QueueType.Complex)
complexRequests.Sort(New DefaultSortByImportDateAndSurname)
dtgComplexQueue.ItemsSource = New TriageMenuDataMembers(complexRequests)
Return complexRequests
End FunctionHow can I get a copy of the
SortDescriptionCollection
so that the collection exists after the DataGrid has been rebound? I don't seem to have this problem in other areas of my app so I'm thinking it has something to do with the PopulateComplex fn..? :confused: Thanks