For those who think the MVP title comes with divine wisdom, I have a disappointing announcement to make: it does not. Recently I discovered (or actually was told) something pretty elementary that I missed all that time: how to draw more or less translucent lines or shapes on a Windows Phone 8 map.
To the right you see a few shapes that I draw on the screen during my 3rd WpDevFusion Mapping session demo. The basic piece for such a shape is very simple:
var line = new MapPolygon
{
StrokeThickness = 2,
FillColor=Colors.Purple,
StrokeColor = Colors.Red,
StrokeDashed = false
};
But what we want is more or less translucent shapes. That turns out to be insanely easy:
var fill = Colors.Purple;
var stroke = Colors.Red;
fill.A = 80;
stroke.A = 80;
var line = new MapPolygon
{
StrokeThickness = 2,
FillColor = fill,
StrokeColor = stroke,
StrokeDashed = false
};
A Color has four elements : R(ed), G(reen), B(lue) and A(lpha). The last ones determines the opacity of XAML elements, but apparently also that of map shapes. Both fill and stroke are now about 80/255th (or 31%) opaque – or 69% translucent.
And that’s all there is to it. If you don’t mind, I will leave the demo solution for as exercise for the reader this time ;)

No comments:
Post a Comment