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 SubSource="{StaticResource customerSampleData}">Source="{StaticResource customerSampleData}">imageListBuffer.ItemsSource = args.FeatureSet.Features
<UserControl.Resources>
<!--<CollectionViewSource x:Name="dataSource" Source="{StaticResource imageListBuffer}">
<CollectionViewSource.SortDescriptions>
<compMod:SortDescription PropertyName="NAME" Direction="Ascending"/>
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>-->
</UserControl.Resources>
<Grid Grid.Column="2">
<StackPanel Orientation="Vertical" Margin="5" HorizontalAlignment="left" VerticalAlignment="top" >
<Grid x:Name="IdentifyGridBuffer" HorizontalAlignment="left" VerticalAlignment="Top" Margin="0,2,0,0" MouseEnter="TurnOnChurchBufferedGraphics">
<Rectangle Fill="#CC5C90B2" Stroke="Gray" Opacity=".6" RadiusX="10" RadiusY="10" Margin="0,0,0,0" >
<Rectangle.Effect>
<DropShadowEffect/>
</Rectangle.Effect>
</Rectangle>
<StackPanel x:Name="IdentifyResultsPanelBuffer" Height="190" Width="300" Orientation="Vertical" Margin="0,20,0,0" HorizontalAlignment="Center">
<Grid x:Name="resultsPanelBuffer" Width="260"
HorizontalAlignment="Center" VerticalAlignment="Top"
Margin="10,40,10,10">
<Border Padding="2" Style="{StaticResource darkBorder}">
<StackPanel Orientation="Vertical" >
<ListBox x:Name="imageListBuffer" Height="120" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Visible"
BorderThickness="0"
Foreground="White" Background="Transparent"
SelectionChanged="imageListBuffer_SelectionChanged"
ItemsSource="Binding Source={StaticResource dataSource}" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" >
<!-- QUERY -->
<StackPanel Margin="1">
<TextBlock Foreground="White" Margin="0,4,0,0" VerticalAlignment="Center" Text="{Binding Attributes[TYPE]}" />
</StackPanel>
<StackPanel Margin="5,0,0,0" Orientation="Vertical">
<TextBlock Foreground="White" Text="{Binding Attributes[NAME], StringFormat='Name: \{0\}'}" >
<TextBlock.Effect>
<DropShadowEffect/>
</TextBlock.Effect>
</TextBlock>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Border>
</Grid>
</StackPanel>
</Grid>
</StackPanel>
</Grid>
'..snip
' 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.SortDescriptions.Add(New SortDescription("NAME", 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
' Set the listbox with all the found features.
imageListBuffer.ItemsSource = args.FeatureSet.Features
..snip
Public Class Customers
Inherits ObservableCollection(Of Customer)
Public Sub New()
Add(New Customer("Michael", "Anderberg", "12 North Third Street, Apartment 45"))
Add(New Customer("Chris", "Ashton", "34 West Fifth Street, Apartment 67"))
Add(New Customer("Cassie", "Hicks", "56 East Seventh Street, Apartment 89"))
Add(New Customer("Guido", "Pica", "78 South Ninth Street, Apartment 10"))
End Sub
End ClassDim featureSet As FeatureSet = args.FeatureSet ' Set the listbox with all the found features. Dim enumGraphics = From SelectedGraphic In args.FeatureSet SetOrder By TryCast(SelectedGraphic.Attributes("NAME"), String) Ascending ' imageListBuffer.ItemsSource = args.FeatureSet.Features imageListBuffer.ItemsSource = enumGraphics ' Private _XYLocation As MapPoint = Nothing 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) selectedGraphic.Symbol = TryCast(LayoutRoot.Resources("StrobeMarkerSymbol_Blue"), ESRI.ArcGIS.Client.Symbols.Symbol) _resultsGraphicsLayer.Graphics.Add(selectedGraphic) 'graphicsLayer.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
var sortedGraphics = from g in graphicsLayer.Graphics orderby (double)g.Attributes["Distance"] ascending select g;