John F Accidents: 20 Fires: 34 Amy Accidents: 20 Fires: 34 etc
Dim queryPolice As New ESRI.ArcGIS.Client.Tasks.Query()
queryPolice.OutFields.Add("*")
queryPolice.ReturnGeometry = True
' Return all features
queryPolice.Where = "1=1"
queryPolice.OutSpatialReference = MyMap.SpatialReference
queryTaskPolice.ExecuteAsync(queryPolice)Dim variables, varaibles For Each selectedGraphic As Graphic In args.FeatureSet.Features If then calculate variables set to placeholders that will report in listbox End If Next selectedGraphic
Dim results = From g In graphicCollection _
Group g By DirectCast(g.Attributes("Officer"), String) Into r _
Select Officer = r.Key, Incidents = r.Sum(Function(i) CInt(i.Attributes("Incident"))) Dim results = From g In graphicCollection _
Group g By DirectCast(g.Attributes("Officer"), String) Into r() _
Select Officer = r.Key, Incidents = r.Sum(Function(i) CInt(i.Attributes("Incident")))
Dim categories = From p In products _
Group p By p.Category Into Group _
Select Category, TotalUnitsInStock = Group.Sum(Function(p) p.UnitsInStock)
Dim q = From e In db.Employees _
Select Name = e.FirstName & " " & e.LastName, Phone = e.HomePhone
var results = from g in graphicCollection
group g by (string)g.Attributes["Officer"] into r
select new { Officer = r.Key, Incidents = r.Sum(i => Convert.ToInt32(i.Attributes["Incident"])) };
For Each item In results
MessageBox.Show(String.Format("Officer {0} has {1}", item.Officer, item.Incidents))
' TRY 1
Me.Results.ItemsSource = (String.Format("Officer {0} has {1}", item.Officer, item.Incidents))
' TRY 2
Me.Results.ItemsSource = results
Next item
Results.ItemsSource = results
<TextBlock Text="{Binding Attributes[Officer]}"/>
<TextBlock Text="{Binding Attributes[Incident]}" Grid.Column="2"/>
<TextBlock Text="{Binding Officer}"/>
<TextBlock Text="{Binding Incidents}" Grid.Column="2"/>
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("System.Windows")]
Binding to anonymous types is supported in SL4 by adding this line in your AssemblyInfo.cs[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("System.Windows")]
When you don't see elements in your ListBox, check Binding statements if they still apply to the data type of your ItemsSource.
Dim results = From g In graphicCollection
Group g By GroupKey = CStr(g.Attributes("Officer")) Into r = Group
Select New With {Key .Officer = GroupKey, Key .Incidents = r.Sum(Function(i) Convert.ToInt32(i.Attributes("Incident")))}
Me.ListboxResults.ItemsSource = results
For Each item In results
MessageBox.Show(String.Format("Officer {0} has {1}", item.Officer, item.Incidents))
Next item
<Button Content="calculate total" VerticalAlignment="Top" HorizontalAlignment="Center" Click="Button_Click"/>
<ListBox x:Name="ListboxResults">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Officer}" Grid.Column="0"/>
<TextBlock Text="{Binding Incident}" Grid.Column="1"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Assembly: System.Runtime.CompilerServices.InternalsVisibleTo("System.Windows")>
Private Sub ExecutePIDButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
' OPEN THE RESULTS PANEL TO DISPLY RESULTS
ShowResultsPanel.Begin()
Dim queryTaskPolice As New QueryTask("http://gis.somewhere.org/MapServer/0")
AddHandler queryTaskPolice.ExecuteCompleted, AddressOf QueryTaskPolice_ExecuteCompletedListBox
AddHandler queryTaskPolice.Failed, AddressOf QueryTaskPolice_FailedSearchListBox
Dim queryPolice As New ESRI.ArcGIS.Client.Tasks.Query()
queryPolice.OutFields.Add("Officer, Incident, IncidentNum")
queryPolice.ReturnGeometry = True
' Return all features
queryPolice.Where = "1=1"
queryPolice.OutSpatialReference = MyMap.SpatialReference
queryTaskPolice.ExecuteAsync(queryPolice)
End Sub
Private Sub QueryTaskPolice_ExecuteCompletedListBox(ByVal sender As Object, ByVal args As ESRI.ArcGIS.Client.Tasks.QueryEventArgs)
Dim featureSet As FeatureSet = args.FeatureSet
' WORK WITH THE RESULTS FROM THE QUERY FOR INCIDENTS
' Create a list by Incident and then talley the number of each
Dim results = From g In featureSet
Group g By GroupKey = CStr(g.Attributes("Incident")) Into r = Group
Select New With {Key .Incident = GroupKey, Key .IncidentNums = r.Sum(Function(i) Convert.ToInt32(i.Attributes("IncidentNum")))}
Me.Results.ItemsSource = results
End Sub <StackPanel x:Name="IdentifyResultsPanelBufferIncidents_Police" Height="300" Width="175" Orientation="Vertical" Margin="0,0,0,0" HorizontalAlignment="Center">
<Grid x:Name="resultsPanelBufferIncidents_Police" Width="175" Height="300"
HorizontalAlignment="Center" VerticalAlignment="Top"
Margin="0,0,0,0">
<StackPanel Orientation="Vertical">
<StackPanel>
<Button Content="calculate total" VerticalAlignment="Top" HorizontalAlignment="Center" Click="Button_Click"/>
<ListBox x:Name="Results">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Incident, StringFormat='Type: \{0\}'}" Grid.Column="0"/>
<TextBlock Text=" has " Foreground="Black" Grid.Column="1" />
<TextBlock Text="{Binding IncidentNums}" Grid.Column="2"/>
<TextBlock Text=" incident" Foreground="Black" Grid.Column="3"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</StackPanel>
</Grid>
</StackPanel>