Christine, Mike, blomm or anyone else interested in this post!I finally found a little time to try and get the SDK spatial tool to work with muiltiple layers, using a combo drop down box. I'm almost there and now I'm having a freeze about how to handle the xaml end........populating the headers and fields for the datagrid. This Part:
<!-- Query Results -->
<slData:DataGrid x:Name="QueryDetailsDataGrid" AutoGenerateColumns="False" HeadersVisibility="Column" Background="White"
IsReadOnly="True" HorizontalScrollBarVisibility="Hidden"
RowStyle="{StaticResource MyCustomRow}" CanUserSortColumns="True"
SelectionChanged="QueryDetailsDataGrid_SelectionChanged"
LoadingRow="QueryDetailsDataGrid_LoadingRow">
<slData:DataGrid.Columns>
<slData:DataGridTextColumn Binding="{Binding Attributes[BVUNIQUEID]}" Header="BV UNIQUE ID"/>
<slData:DataGridTextColumn Binding="{Binding Attributes[CREZ_NAME]}" Header="CREZ NAME"/>
<slData:DataGridTextColumn Binding="{Binding Attributes[SOLARTH_MW]}" Header="SOLARTH MW"/>
<slData:DataGridTextColumn Binding="{Binding Attributes[ACRES]}" Header="ACRES"/>
</slData:DataGrid.Columns>
</slData:DataGrid>
</ScrollViewer>
</Grid>
</userControls:CollapsiblePanel>
<!-- End Query Results -->
So Like I said I add a drop down list in xaml, which is used to select which layer is active.
<!--Jays DropDown List / Combo Box for Spatial Selection -->
<ComboBox x:Name="LayerListDropDown" Width="150" Height="30" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="0,5,0,5" SelectionChanged="DropDown_ItemSelected">
<ComboBoxItem Content="layer1" />
<ComboBoxItem Content="layer2" />
<ComboBoxItem Content="layer3" />
</ComboBox>
<!--Jays DropDown List / Combo Box for Spatial Selection -->
In my code behind I add this
#region LayerListDropDown Code
//layerlist dropdown code
private void DropDown_ItemSelected(object sender, EventArgs e)
{
if (LayerListDropDown.SelectedIndex == 0)
{
UrlServiceId = "http://dgpdch01/ArcGIS/rest/services/testD2/MapServer/14";
}
else if (LayerListDropDown.SelectedIndex == 1)
{
UrlServiceId = "http://dgpdch01/ArcGIS/rest/services/testD2/MapServer/18";
}
else
{
UrlServiceId = "http://dgpdch01/ArcGIS/rest/services/testD2/MapServer/19";
}
_queryTask = new QueryTask(UrlServiceId);
_queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
_queryTask.Failed += QueryTask_Failed;
}
#endregion
and in the method private void MyDrawSurface_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs args) I add this
//Jay add for if else drop list.
if (LayerListDropDown.SelectedIndex == 0)
{
query.OutFields.AddRange(new string[] { "BVUNIQUEID", "ACRES", "CREZ_NAME", "SOLARTH_MW" });
}
else if (LayerListDropDown.SelectedIndex == 1)
{
query.OutFields.AddRange(new string[] { "PROJECTTYP", "CREZ_BVID", "CREZ_NAME", "MW", "CALCULATED"});
}
else
{
query.OutFields.AddRange(new string[] { "PROJECT_ID", "ASSOC_CREZ", "ACRES", "CREZ_BVID", "GISCALC" });
}
So now the user can select a layer and spatial query on the selected layer but the field name it is trying to pull and field headers are static. Also right now it is only working with polygon layers. Once I get polys down I will write story/animation so lines and markers work butWhat should I do to switch what is being Generater in the QueryDetailsDataGrid GRID (the first xaml code I posted or to be really specific I only need to change the column data....see below). Should I handle this with hiding and showing animation/grids or is there a way to do like a if/else in xaml or add some event trigge and checked if that is checked (EventTrigger EventName="Checked") but the check should be the drop down list so it would be really easy to just do an if/else Late in the day and I can't think......plus I'm a hack.
<slData:DataGrid.Columns>
<slData:DataGridTextColumn Binding="{Binding Attributes[BVUNIQUEID]}" Header="BV UNIQUE ID"/>
<slData:DataGridTextColumn Binding="{Binding Attributes[CREZ_NAME]}" Header="CREZ NAME"/>
<slData:DataGridTextColumn Binding="{Binding Attributes[SOLARTH_MW]}" Header="SOLARTH MW"/>
<slData:DataGridTextColumn Binding="{Binding Attributes[ACRES]}" Header="ACRES"/>
</slData:DataGrid.Columns>