Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am wanting to use the FeatureDataGrid to display data. The problem is I have more than one layer that contains data that needs to be displayed.

This is how you use the DataGrid for one layer:

private void MyMap_Loaded(object sender, RoutedEventArgs e)
        {
            MyDataGrid.Map = MyMap;
            MyDataGrid.GraphicsLayer = MyMap.Layers[1] as ESRI.ArcGIS.Client.GraphicsLayer;
            MyFeatureDataForm.FeatureLayer = MyMap.Layers[1] as ESRI.ArcGIS.Client.FeatureLayer;
        }

This is the XAML for my map:

<esri:Map.Layers>
                    <esri:ArcGISTiledMapServiceLayer ID="MyLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>

                    <esri:FeatureLayer ID="Hydrant" 
                                       Url="http://localhost:6080/arcgis/rest/services/CalvertCity_Test_Server/FeatureServer/0" 
                                       Renderer="{StaticResource Renderer_Hydrant}"
                                       MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp" 
                                       DisableClientCaching="True"
                                       OnDemandCacheSize="0"
                                       Mode="OnDemand"
                                       AutoSave="False"
                                       OutFields="*" />
                    <esri:FeatureLayer ID="WaterValves" 
                                       Url="http://localhost:6080/arcgis/rest/services/CalvertCity_Test_Server/FeatureServer/1" 
                                       Renderer="{StaticResource Renderer_WaterValves}"
                                       MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp" 
                                       DisableClientCaching="True"
                                       OnDemandCacheSize="0"
                                       Mode="OnDemand"
                                       AutoSave="False"
                                       OutFields="*" />
                    <esri:GraphicsLayer ID="CandidateGraphicsLayer">
                        <esri:GraphicsLayer.MapTip>
                            <Grid>
                                <Rectangle Stroke="Gray"  RadiusX="10" RadiusY="10" Fill="#77FF0000" Margin="0,0,0,5" >
                                    <Rectangle.Effect>
                                        <DropShadowEffect/>
                                    </Rectangle.Effect>
                                </Rectangle>
                                <Rectangle Fill="#DDFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,15" />
                                <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="30,20,30,30">
                                    <TextBlock Text="{Binding [Address]}" HorizontalAlignment="Left" Foreground="Black" />
                                </StackPanel>
                            </Grid>
                        </esri:GraphicsLayer.MapTip>
                    </esri:GraphicsLayer>
                </esri:Map.Layers>                
            </esri:Map>

I thought about trying to pull the layer for the selected graphic, but I am not sure as to how to do that. If you need any more information or want me to explain further, let me know.

share|improve this question
    
In this case, do you need to show data on all the hydrants, watervalves, and address results in the map extent, or some combination of those? –  raykendo Jul 1 '13 at 20:35
    
Just the hydrant and watervalves. My feature layers. I need the data to show in the featuredatagrid. Right now it will only show one of the other. –  JLott Jul 1 '13 at 20:45

1 Answer 1

up vote 2 down vote accepted

The FeatureDataGrid is connected to a single GraphicsLayer or FeatureLayer (which inherits from GraphicsLayer), and uses the attributes to autogenerate column names. Mixing two layers that (probably) have different column names would look confusing on a single table, since some records would fill in some columns, and other records wouldn't. I think that's why the FeatureDataGrid enforces binding to a single layer.

That being said, if you need to show data for two FeatureLayers at the same time, use two FeatureDataGrids, each one bound to a different layer. If you don't have enough room on the screen, I'd recommend a TabControl with a FeatureDataGrid in each TabItem.

Or, you could have a single FeatureDataGrid and a ComboBox or RadioButtons that let you switch the FeatureDataGrid's GraphicsLayer and FeatureLayer between the two layers.

share|improve this answer
    
The combobox/radiobutton idea is great! I should have thought of that. Do you know if there is a way to tell which feature layer a graphic is associated with when the user clicks on it? I thought about setting the feature layer property of the FeatureDataGrid to the feature layer of the graphic selected, but I am not sure about how to go about that. –  JLott Jul 2 '13 at 13:23
    
For each FeatureLayer, Create a MouseLeftButtonDown event handler that sets the feature layer property of the FeatureDataGrid to that FeatureLayer. The MouseLeftButtonDown event will trigger when you click on a graphic in the FeatureLayer, and it has access to the graphic you clicked. MouseLeftButtonDown Event: resources.arcgis.com/en/help/runtime-wpf/apiref/… –  raykendo Jul 2 '13 at 16:02
    
I love when I just look over simple solutions. Thanks again! –  JLott Jul 2 '13 at 17:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.