domenica 16 giugno 2013

Coding4Fun - ThemedImageConverter

When you publish an application, you need to meet the requirement 5.5.2 from Dev Center:
"App content, such as text and visual elements, must be visible and legible regardless of the phone theme without panning horizontally or zooming.."

The example is when you have an image with the same color of background theme.
What you can do?
- select a different color for image.
- manage the image source swap from code behind.
- the best practice is to use the ThemedImageConverter from Coding4Fun Toolkit.

Let's go:
Download the Coding4Fun Toolkit from NuGet or Codeplex.

Add the static resource in your page:
<c4fun:themedimageconverter x:key="ThemedImageConverter"></c4fun:themedimageconverter>

Use this simple converter in your image:
<Image Source="{Binding Converter={StaticResource ThemedImageConverter}, ConverterParameter={StaticResource PhoneBackgroundColor}}" DataContext="/Assets/{0}/img.png" />

You can check also the InverseThemedImageConverter to swap from light and dark themes.


Nessun commento:

Posta un commento