0

How can I create a Style with WPF that applies a color layer to ANY image on mouse over as described below. Image has a transparent background.

Example 1 (normal and mouseover):

enter image description here

Example 2 (normal and mouseover):

enter image description here

For example, let's say I have a RadioButton with an Image as its Content. I planned defining a ControlTemplate to do this but I'm stuck with how to apply a color "layer" to the image.

<RadioButton Template="{StaticResource ColorTemplate}">
    <Image Source="/MyProject;component/someimage.png"/>
</RadioButton>

<ControlTemplate x:Key="ColorTemplate">
     <Border Background="Transparent">
          <ContentPresenter Content="{TemplateBinding Content}"/>
     </Border>
     <ControlTemplate.Triggers>
          <--CAN THIS BE ACHIEVED THROUGH TRIGGERS?-->
     </ControlTemplate.Triggers>
</ControlTemplate>

Is it possible to make this a generic style in XAML that could be applied to any image so that there would be no need to include two (or more) images of the same only to achieve these color effects.

Nuts
  • 2,755
  • 6
  • 33
  • 78
  • See this question: http://stackoverflow.com/questions/24752517/how-to-replace-one-set-of-color-shades-with-another-set?lq=1 – qqbenq Jan 23 '15 at 11:53
  • Looks like the correct idea but could that C# code be made work directly in XAML without code-behind? – Nuts Jan 23 '15 at 13:34

0 Answers0