Hey Jennifer, I tried to set binding to a feature datagrid at run-time through code-behind. I took your suggestion but the binding set seems not working because the datagrid disapear. Initially I bind it with a feature layer but at run time I need re-set the binding to other layers. Below is my code: //binding feature datagrid to target layer Binding bMap = new Binding("bMap"); bMap.Source = MyMap; Binding bLayer = new Binding("bLayer"); bLayer.Source = MyMap.Layers["RegionLayer"]; MyDataGrid.SetBinding(FeatureDataGrid.MapProperty, bMap); MyDataGrid.SetBinding(FeatureDataGrid.GraphicsLayerProperty, bLayer);Initial setting for feature datagrid in XAML:<esri:FeatureDataGrid x:Name="MyDataGrid" Background="White" Map="{Binding ElementName=MyMap}" GraphicsLayer="{Binding ElementName=MyMap, Path=Layers.[PPP_StateLayer]}" />Any idea what's wrong?
//binding feature datagrid to target layer Binding bMap = new Binding("bMap"); bMap.Source = MyMap; Binding bLayer = new Binding("bLayer"); bLayer.Source = MyMap.Layers["RegionLayer"]; MyDataGrid.SetBinding(FeatureDataGrid.MapProperty, bMap); MyDataGrid.SetBinding(FeatureDataGrid.GraphicsLayerProperty, bLayer);
<esri:FeatureDataGrid x:Name="MyDataGrid" Background="White" Map="{Binding ElementName=MyMap}" GraphicsLayer="{Binding ElementName=MyMap, Path=Layers.[PPP_StateLayer]}" />
MyDataGrid.Map = MyMap; MyDataGrid.GraphicsLayer = MyMap.Layers["RegionLayer"];
Binding bMap = new Binding("bMap"); Binding bLayer = new Binding("bLayer");
Binding bMap = new Binding(""); Binding bLayer = new Binding(""); bLayer.Source = MyMap.Layers["RegionLayer"];
You can look at the XAML code in this sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#QueryRelatedRecords to bind to the attributes. You can set ItemsSource in code or in XAML, I believe it is something like this:ItemsSource="{Binding Graphics}" DataContext="{Binding ElementName=MyMap, Path=Layers[MyLayerId]}".If you are using FeatureDataGrid, this is a good example: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#FeatureDataGrid
If each row corresponds to a graphic, you will have access to the graphic.Attributes. I suggest you look into the Related Tables sample, specifically this event handler in code-behind: SelectedWellsTreeView_SelectedItemChanged
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.