Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to Maintain Copy of SortDescriptionCollection After DataGrid Rebind

How to Maintain Copy of SortDescriptionCollection After DataGrid Rebind

Scheduled Pinned Locked Moved Visual Basic
questionhelptutorial
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    D Dubya
    wrote on last edited by
    #1

    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 the dtg.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 Function

    How 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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups