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 bufferNote: BUFFER_DISTANCE is not a field in the feature...its being created or set below in blueAny 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