views:

1093

answers:

2

Hi. I'm trying to use the OpacityMask property combined with a VisualBrush so that when you drag an image over another control (such as another image, rectangle, or any other control), the part of the image that is over the second control has a different opacity. That is, the image has some non-zero base opacity, and any part of the image that is over another control has a different (again, non-zero) opacity.

Is this possible simply using VisualBrush and OpacityMask? Or is a more complex approach required?

Thanks!

Edit: I'm trying to make the image have some lower opacity (such as 0.5), and the part being dragged over the control have a higher opacity (such as 1.0). I originally left out this detail, which is important to the approach taken.

+1  A: 
  • No masks
  • Define visual brush for the control
  • Paint shape right on top of the control with that brush
  • Drag image between the shape and the control
  • Set opacity of the brush to achieve desired effect
ima
I haven't yet tried this, but it seems like this would be great if I wanted to have a lower opacity over the control. What if I wanted a higher opacity (i.e. have the image at Opacity = 0.5 and the part over the control at Opacity = 1.0)? I would think that this approach can only lower the image's opacity, not increase it. Please correct me if I'm wrong. Thanks. :)
impulse3d
I notice that I did not originally specify this requirement in my question. I have edited the question to include this.
impulse3d
deleted hasty and wrong updates
ima
A: 
impulse3d
As I mention, if you want the base opacity > masked opacity, I don't believe you can use this approach since it uses two images and you can only add opacity, not subtract it. The approach ima suggests would probably be best for a base opacity > masked opacity. But I believe my solution is a great way to do it for the reverse.
impulse3d