1

I have two Imagebrushes, as you see they are exactly the same but one is with opacity.

<ImageBrush x:Key="One" ImageSource="AluSilver.jpg" TileMode="Tile" Viewport="0,0,200,200" ViewportUnits="Absolute" Opacity="0.5" />

<ImageBrush x:Key="Two" ImageSource="AluSilver.jpg" TileMode="Tile" Viewport="0,0,200,200" ViewportUnits="Absolute" />

Since Brushes are not styleable I must create these two.

Is there a way to bypass this?

Cœur
  • 37,241
  • 25
  • 195
  • 267
GreenEyedAndy
  • 1,485
  • 1
  • 14
  • 31
  • 3
    Maybe you're applying the opacity at a too low level (i.e. the brush) instead of applying it to the control using the brush ? – franssu Feb 19 '14 at 16:14
  • Set the opacity on control where this brush is getting applied eventually. (May be over `Image` control). – Rohit Vats Feb 19 '14 at 18:47

1 Answers1

0

I dont know why you doing all that because brushes allow manipulation.

Take a look at this:

<Rectangle Width="100" Height="100">
  <Rectangle.Fill>
    <SolidColorBrush x:Name="MyAnimatedBrush" Color="Orange" />
  </Rectangle.Fill>
  <Rectangle.Triggers>
    <EventTrigger RoutedEvent="Rectangle.MouseLeftButtonDown">
      <BeginStoryboard>
        <Storyboard>
          <DoubleAnimation
            Storyboard.TargetName="MyAnimatedBrush"
            Storyboard.TargetProperty="Opacity"
            To="0.0" Duration="0:0:0.5" AutoReverse="True" />
        </Storyboard>
      </BeginStoryboard>
    </EventTrigger>        
  </Rectangle.Triggers>
</Rectangle>

You may change opacity as well as color or whatever you need.

dev hedgehog
  • 8,698
  • 3
  • 28
  • 55