Select to view content in your preferred language

New attribute binding

861
2
Jump to solution
09-06-2013 10:45 AM
JeffRogholt
Emerging Contributor
Not every graphic in our feature dataset has geometry and I'd like to add a column to the datagrid to identify this.  Before assigning the feature layer to the datagrid graphics layer, I loop thru the graphics and add an attribute called "HasShape" and assign a value of "True" or "False" (string data type not boolean).

When I debug my code, the attribute list includes "HasShape" but this is the exception I get when I bind the data to the grid:
'HasShape' property not found on 'ESRI.ArcGIS.Client.Toolkit.DataSource.TempTypeMinus2021084955'

Here's the code I'm using to add the attribute:

Dim lyr As New ESRI.ArcGIS.Client.FeatureLayer lyr = CType(Mainpage.MyMap.Layers("MyFeatureLayer"), ESRI.ArcGIS.Client.FeatureLayer)  For Each item As ESRI.ArcGIS.Client.Graphic In lyr.Graphics     If item.Geometry Is Nothing Then       item.Attributes.Add("HasShape", "False")        Else       item.Attributes.Add("HasShape", "True")     End If Next  Mainpage.MyDataGrid.GraphicsLayer = Mainpage.MyMap.Layers("MyFeatureLayer")


I do NOT auto generate the datagrid's columns so here is my code to add the "HasShape" column:

        Dim col As New DataGridTextColumn         col.Binding = New Windows.Data.Binding("HasShape")         col.Header = "Has Shape"         col.Width = New DataGridLength(80.0)         col.IsReadOnly = True         MyDataGrid.Columns.Add(col)


Please let me know if this is possible or maybe there's a better way to identify if there's a geometry.

Thanks,
Jeff
0 Kudos
1 Solution

Accepted Solutions
DenisT
by
Deactivated User
My fault, just noticed you were using FeatureDataGrid.

In that case you can add your new Field description to lyr.LayerInfo.Fields.
Not sure if there will be any side-effects during feature layer editing.

View solution in original post

0 Kudos
2 Replies
DenisT
by
Deactivated User
Try the following code:
col.Binding = New Windows.Data.Binding("Attributes[HasShape]")


Please let me know if this is possible or maybe there's a better way to identify if there's a geometry.

You can bind to the Geometry itself but use a custom IValueConverter implementation. Then the geometry changes will be tracked automatically.
0 Kudos
DenisT
by
Deactivated User
My fault, just noticed you were using FeatureDataGrid.

In that case you can add your new Field description to lyr.LayerInfo.Fields.
Not sure if there will be any side-effects during feature layer editing.
0 Kudos