Select to view content in your preferred language

Inconsistency in API

645
3
08-26-2010 06:44 AM
DonnieHolmes
Occasional Contributor
I have created a class that acts as a configuration manager for my application. It basically deserializes an xml file into a settings object with strongly-typed properties.  This object gets created in App.xaml and then I bind to the strongly-typed properties from xaml in my main page.

The idea here is to maintain config settings such as map layer urls in an external file that can be updated at the server (similar to app.config or web.config). This way, updating the Url property of a map layer can be done easily without the need to access the xaml, and no recompiling is necessary.

Problem: It appears that only a few of the map layer types have a "Url" property that is backed by a dependency property (binding support).

Examples:
For FeatureLayer, this works fine:

Url="{Binding Source={StaticResource ConfigMgr},Path=Settings.TestLayerUrl}"


For ArcGISDynamicMapServiceLayer, this thows a XamlParsingException:

Url="{Binding Source={StaticResource ConfigMgr},Path=Settings.MapServiceUrl}"


Unless I'm missing something, it seems like this is happening because FeatureLayer.Url is backed by a dependency property and AcGISDynamicMapServiceLayer.Url is not.  It seems like the ESRI API should be consistently implementing this property as a dependency property for all layers that have the property.

Thoughts? Suggestions? Workarounds?
Thanks.
0 Kudos
3 Replies
DonnieHolmes
Occasional Contributor
No comments from the ESRI folks?

I'm mostly curious if this is by design or if this is something that we could possibly see changed in 2.1 or a future release.

Thanks.
0 Kudos
dotMorten_esri
Esri Notable Contributor
This is something that we could possibly see changed in 2.1 or a future release.
0 Kudos
DonnieHolmes
Occasional Contributor
Update: We found a pretty nice workaround for this in one of Morten's blog posts:

http://www.sharpgis.net/post/2009/05/04/Using-surrogate-binders-in-Silverlight.aspx

Basically, you can create a static class that contains an Attached Property (which you can bind to).  Then, in the DependencyPropertyChanged handler you turn around and set the Url property on the map layer. That ends up looking something like this:

<esri:ArcGISDynamicMapServiceLayer ID="TestLayer" 
                                               local:SurrogateBind.Target="Url"
                                               local:SurrogateBind.Value="{Binding Source={StaticResource ConfigMgr},Path=Settings.MapServiceUrl}" />


So far, this seems like a pretty acceptable workaround.
0 Kudos