Select to view content in your preferred language

How fesible is to use MVVM pattern in Arcgis 10 Silver Light

926
5
08-16-2010 03:26 AM
roufbaba
Deactivated User
Hi,

I want to implement MVVM pattern in my arcgis 10 silver light application. I need some expert comments on it. I am new to Silver Light. Anybody's help will be appreciated.


Thanks and Best Regards
Rouf
0 Kudos
5 Replies
JenniferNery
Esri Regular Contributor
We are aware that some properties in the API are either not bindable or get their value after some event has fired, which makes observing MVVM pattern a little difficult to achieve. While we are still working on making our API more "MVVM-friendly," I have seen users post here that they are following MVVM pattern using our API so I guess it's not impossible to do.
0 Kudos
roufbaba
Deactivated User
Hi jennifer,

Thakyou very much for the reply. Could you please explain the below statement further

"We are aware that some properties in the API are either not bindable or get their value after some event has fired"

Thanks and Best Regards
Rouf
0 Kudos
JenniferNery
Esri Regular Contributor
Map's Extent or FeatureLayer's Where properties, for example are not bindable properties. So if you have a model that needs to manage these properties, you cannot do so with a binding statement.

Or if you would like to update the GraphicsLayer's Graphics property with some binding statement like Graphics={Binding Graphics} assuming you have already set the Map's DataContext to your model. This too will fail because the Map will first attempt to set all the properties of its layers prior to determining what DataContext it is in. The resulting binding statement then will be similar to Graphics = null since it was not able to resolve the DataContext. This will throw an exception because Graphics need to be a GraphicsCollection.  You can look at this post for a workaround: http://forums.arcgis.com/threads/9868-Bind-graphics-of-GraphicLayer.-Bind-GraphicCollection

To really know if MVVM is feasible with our API, you have to try and make a list of stumbling blocks (if any). The ones I listed above are things I've experienced when I try MVVM approach. Our API was designed before MVVM was encouraged in SL but we are working towards this goal and we welcome any feedbacks.
0 Kudos
dotMorten_esri
Esri Notable Contributor
In most cases you can work around the few binding limitations using Attached Properties (AP) and listening for the property changed event. A quick google on AP should get you started.
0 Kudos
roufbaba
Deactivated User
Hi,

Thankyou for your support. I will try these workarounds and let you know If i face any issue.

Regards
Rouf
0 Kudos