Collection View Source

630
4
02-01-2011 12:26 PM
JayKappy
Occasional Contributor
I am trying to Sort the results from a buffer using Collection View Source...I think I am on the right path here but cant seem to get the sort to perform or refresh the listbox.
In this case I am trying to sort by the Buffer Distance being created fro each selected feature found inside the buffer
Note: BUFFER_DISTANCE is not a field in the feature...its being created or set below in blue

Any quick thoughts?
    Private Sub QueryTask_ExecuteCompletedBuffer2(ByVal sender As Object, ByVal args As QueryEventArgs)

      ' Set up the collection View Source in order to Sort the results of the query by DISTANCE       
                Dim cs As New CollectionViewSource
                cs.SortDescriptions.Add(New SortDescription("BUFFER_DISTANCE", ListSortDirection.Ascending)) 
                cs.Source = args.FeatureSet.Features        
     ' Apply the sort to the listbox       
                imageListBuffer.ItemsSource = cs.View        
     ' refresh the listbox        
                cs.View.Refresh()

        Dim featureSet As FeatureSet = args.FeatureSet
        imageListBuffer.ItemsSource = args.FeatureSet.Features

        ' Set the Buffer Variable for the Center Point of the buffer to a MAPPOINT not String to the variable being set 
        ' in the GeometryService_BufferCompleted2...the Variable is globally define at the to of the code page
        Dim _XYLocationBuffer As MapPoint = Nothing
        _XYLocationBuffer = _XYLocation

        If args.FeatureSet.Features.Count < 1 Then
            MessageBox.Show("No features found")
            Return
        End If
        For Each selectedGraphic As Graphic In args.FeatureSet.Features
            selectedGraphic.Symbol = TryCast(LayoutRoot.Resources("DefaultMarkerSymbol"), ESRI.ArcGIS.Client.Symbols.Symbol)
            _resultsGraphicsLayer.Graphics.Add(selectedGraphic)

            ' Get the center point of each selected graphic found in the buffer
            Dim c As ESRI.ArcGIS.Client.Geometry.MapPoint = selectedGraphic.Geometry.Extent.GetCenter()
            ' Call the GetDistance Function...Set the Distance to the BUFFER_DISTANCE variable for each graphic, for display in the listbox            
             selectedGraphic.Attributes("BUFFER_DISTANCE") = GetDistance(_XYLocationBuffer, c)
       
 Next selectedGraphic

    End Sub
0 Kudos
4 Replies
JayKappy
Occasional Contributor
.................................................
0 Kudos
JayKappy
Occasional Contributor
no one out there has ever used CollectionViewSource to sort a listbox?  Just looking to see if I am doing this right or maybe even a hint towards some documentation....I have seen a few ways to do this but cant seem to get it to work...my post above seems to make sense but dont know if I need anything in the xaml file to tie it together.....

THanks
0 Kudos
derekswingley1
Frequent Contributor
This is the JavaScript API forum. Doubt you'll get much help with VB here...
0 Kudos
MeConfused
New Contributor
AHHHHHH didnt see that thanks man
0 Kudos