Select to view content in your preferred language

How to use GraphicsSource property in an ArcGISLocalFeatureLayer?

1284
1
Jump to solution
04-03-2014 08:51 AM
Labels (1)
Cristian_Galindo
Occasional Contributor III
DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far???

I am creating an ArcGISLocalFeatureLayer, but i want to use the GraphicsSource property due an MVVM approach:
                var localCenterlineServiceMPK = new LocalFeatureService                                                     {                                                         Path = @"myPackage.mpk",                                                         MaxRecords = 100000                                                     };                  localCenterlineServiceMPK.Start();                  var lineLayer = new ArcGISLocalFeatureLayer                                     {                                         Url = localCenterlineServiceMPK.UrlFeatureService + "/0",                                         Service = localCenterlineServiceMPK,                                         ID = "mylayerName",                                         LayerName ="mylayerName",                                         Editable = true,                                         DisableClientCaching = true,                                         AutoSave = false,                                         Mode = FeatureLayer.QueryMode.Snapshot,                                         OutFields = new OutFields { "*" },                                         Graphics = null,                                         GraphicsSource = graphics                                     };                 lineLayer.Initialize();


when the line of the creation is hot, then it throws the following exception:

System.InvalidOperationException occurred   HResult=-2146233079   Message=Graphics collection must be empty before using GraphicsSource.   Source=ESRI.ArcGIS.Client   StackTrace:        at ESRI.ArcGIS.Client.FeatureLayer.OnGraphicsSourceChanged(IEnumerable`1 oldValue, IEnumerable`1 newValue)   InnerException:


I had try to set the Graphics property to null, clear it, but the exception is the same in both cases....the documentation was checked...and i do not see anything related
0 Kudos
1 Solution

Accepted Solutions
MichaelBranscomb
Esri Frequent Contributor
Hi,

By setting either the service property or the url property of the local feature layer it will communicate with the service to populate the graphics collection. I believe the GraphicsSource property of the featurelayer should be considered get/read-only since it is designed to be populated from the service.

If you would like to work with the GraphicsSource property then you may need to consider using a GraphicsLayer instead.

Cheers

Mike

View solution in original post

0 Kudos
1 Reply
MichaelBranscomb
Esri Frequent Contributor
Hi,

By setting either the service property or the url property of the local feature layer it will communicate with the service to populate the graphics collection. I believe the GraphicsSource property of the featurelayer should be considered get/read-only since it is designed to be populated from the service.

If you would like to work with the GraphicsSource property then you may need to consider using a GraphicsLayer instead.

Cheers

Mike
0 Kudos