I kept getting the dreaded XamlParseException: AG_E_PARSER_BAD_PROPERTY_VALUE error! I tried with the StrokeColor as well as the StrokeBrush properties found in my MainViewModel class, to no avail.

publicclassMainViewModel : INotifyPropertyChanged

{

publicMainViewModel()

{

StrokeColor="#FF000000";

StrokeBrush=newSolidColorBrush(Colors.Black);

}

privatestringstrokeColor;

publicstringStrokeColor

{

get { returnstrokeColor; }

set

{

if ( strokeColor!=value )

{

strokeColor=value;

RaisePropertyChanged("StrokeColor");

}

}

}

privateBrushstrokeBrush;

publicBrushStrokeBrush

{

get

{

returnstrokeBrush;

}

set

{

if ( strokeBrush!=value )

{

strokeBrush=value;

RaisePropertyChanged("StrokeBrush");

}

}

}

#region INotifyPropertyChanged Members

publiceventPropertyChangedEventHandlerPropertyChanged;

privatevoidRaisePropertyChanged(stringpropertyName)

{

if ( PropertyChanged!=null )

{

PropertyChanged(this, newPropertyChangedEventArgs(propertyName));

}

}

#endregion

}

So I came up with the following work around, which I know is not pure M-V-VM, but I could not figure out why the previous attempts were not working.

<bing:MapPolygon Loaded="MapPolygon_Loaded"

StrokeThickness="5"

Locations="0,0 0,50 50,50 50,0" />

and in the code behind...

privatevoidMapPolygon_Loaded(objectsender, RoutedEventArgse)

{

varpolygon=senderasMapPolygon;

varmodel=polygon.DataContextasMainViewModel;

polygon.Stroke=model.StrokeBrush;

}

Now, running the application gives us the following result. If anyone knows the cause of this problem, please let me know, otherwise, I hope this work around saves someone else the time it took me trying to resolve it.

I'm glad my post sparked your imagination! I really like the approach you've taken in your Earthquake application. Especially all the binding that's happening on the Map and MapItemsControl. Nicely done.

Have you tried anything similar with the ESRI Silverlight Map control? I was thinking of porting your example to see how well that control plays with your binding concepts. I'm curious if you've already explored that?

Hi, did you ever get binding to work with the MapPolygon class? I am trying to bind StrokeThickness. Looks like that the StrokeThickness Property does not have a Dependency Property, and I am thinking this is the reason it does not work.