Silverlight - MapPolyline Style
i'm trying apply style mappolyline.
i have style defined:
<style x:key="routestyle" targettype="map:mappolyline"> <setter property="stroke"> <setter.value> <solidcolorbrush color="magenta" /> </setter.value> </setter> <setter property="strokethickness" value="10" /> </style>
and error when runs:
the property 'stroke' not found in type 'microsoft.maps.mapcontrol.mappolyline'.
which in contradiction this:
http://msdn.microsoft.com/en-us/library/microsoft.maps.mapcontrol.mappolyline_members.aspx
i wondered if maybe struggling find property because it's declared in base class. tried this:
<style x:key="routestyle" targettype="mapcore:mapshapebase"> <setter property="stroke"> <setter.value> <solidcolorbrush color="magenta" /> </setter.value> </setter> <setter property="strokethickness" value="10" /> </style>
but still got:
the property 'stroke' not found in type 'microsoft.maps.mapcontrol.core.mapshapebase'.
am missing obvious?
to work around issue created 2 attached properties can used object inherits mapshapebase:
#region stroke
public static readonly dependencyproperty strokeproperty = dependencyproperty.registerattached(
"stroke",
typeof(brush),
typeof(bingmapsbindinghelper),
new propertymetadata(strokepropertychangedcallback));
public static brush getstroke(mapshapebase mapshape)
{
return (brush)mapshape.getvalue(strokeproperty);
}
public static void settilesources(mapshapebase mapshape, brush value)
{
mapshape.setvalue(strokeproperty, value);
}
private static void strokepropertychangedcallback(object sender, dependencypropertychangedeventargs eventargs)
{
mapshapebase mapshape = (mapshapebase)sender;
mapshape.stroke = (brush)eventargs.newvalue;
}
#endregion
#region strokethickness
public static readonly dependencyproperty strokethicknessproperty = dependencyproperty.registerattached(
"strokethickness",
typeof(double),
typeof(bingmapsbindinghelper),
new propertymetadata(strokethicknesspropertychangedcallback));
public static double getstrokethickness(mapshapebase mapshape)
{
return (double)mapshape.getvalue(strokethicknessproperty);
}
public static void setstrokethickness(mapshapebase mapshape, double value)
{
mapshape.setvalue(strokethicknessproperty, value);
}
private static void strokethicknesspropertychangedcallback(object sender, dependencypropertychangedeventargs eventargs)
{
mapshapebase mapshape = (mapshapebase)sender;
mapshape.strokethickness = (double)eventargs.newvalue;
}
#endregion
these can used in style setter follows:
<style x:key="routestyle" targettype="map:mappolyline">
<setter property="mapshared:bingmapsbindinghelper.stroke">
<setter.value>
<solidcolorbrush color="magenta" />
</setter.value>
</setter>
<setter property="mapshared:bingmapsbindinghelper.strokethickness" value="10" />
</style>
Bing Maps > Bing Maps WPF, WP7/8/8.1, Silverlight
Comments
Post a Comment