Wp7 applications and OpacityMask!

July 28th, 2011 | by admin | info, mobile application, tech


When writing wp7 applications it is a common task to make sure your app looks consistent in both dark and like themes. In most apps developers use icons, images, image buttons etc. So the question is how can we use the same icons/images in both themes so that they stay consistent with the theme colors? Basically the easiest (but definitely not the best) way is to use the well known approach with two icons, one for dark and another for light themes. A better solution could be to use a single icon/image and OpacityMask.

An opacity mask works by mapping its contents to the element or visual. The alpha channels of each of the brush’s pixels are then used to determine the resulting opacity of the element or visual’s corresponding pixels; the actual color of the brush is ignored. If a given portion of the brush is transparent, the corresponding portion of the element or visual becomes transparent. If a given portion of the brush is opaque, the opacity of the corresponding portion of the element or visual is unchanged. The opacity specified by the opacity mask is combined with any opacity settings present in the element or visual. For example, if an element is 25 percent opaque and opacity mask is applied that transitions from fully opaque to fully transparent, the result is an element that transitions from 25 percent opacity to fully transparent.


Leave a Comment

Make sure you enter the * required information where indicated.

You must be logged in to post a comment.