Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making an image control invert its colors depending on theme

I'm trying to work out how to have an Image control in my Windows Phone application invert its colors based on the global background setting (either "Dark" or "Light") chosen by the user in Settings->Themes->Background.

like image 999
Doug Avatar asked Jan 11 '11 11:01

Doug


2 Answers

There is no built-in way to invert image colors within the framework.

Instead, because of the overhead of doing this on the phone, you should create both versions of the image at design/build time and then choose which version to display from your code by detecting Theme Visibility and Opacity.

like image 84
Matt Lacey Avatar answered Oct 20 '22 16:10

Matt Lacey


I must add that what i did in the end was a continuation of what Matt wrote.

  • create two different images that have different versions of the image (dark and light) and place them in the exact same position
  • set their visibility based on the theme resource

the code looks like this:

<Image Height="30" HorizontalAlignment="Center" Margin="0,0,0,220" Name="imgDark" Stretch="Fill" Visibility="{StaticResource PhoneLightThemeVisibility}" VerticalAlignment="Center" Width="30" Source="/MyApplication;component/imageDarkTheme.png" />
<Image Height="30" HorizontalAlignment="Center" Margin="0,0,0,220" Name="imgLoading" Stretch="Fill" Visibility="{StaticResource PhoneDarkThemeVisibility}" VerticalAlignment="Center" Width="30" Source="/MyApplication;component/imageLightTheme.png" />
like image 22
Doug Avatar answered Oct 20 '22 16:10

Doug