tags:

views:

180

answers:

1

I asked a similar question about this previously, but I did not specify that this needs to work in Partial-Trust mode. Unfortunately both correct answers (using UIElement.BitmapEffect or UIElement.Effect) are not allowed in Partial-Trust, because it requires UIPermissionWindow.AllWindows.

Does anyone know of a way to do something similar to the OuterGlowBitmapEffect in a Partial-Trust app?

+1  A: 

If you need a rectangle outline, you can attach an Adorner with a simple rectangle in it. It's not going to have the glow effect you are looking for, though.

If you need a non-rectangle outline, you can still use Adorner, but you also need to specify opacity mask, based on a visualBrush on your object. You will also have to make the adorner a little bit bigger than the source visual, to make it look like it surrounds the object instead of overlapping it.

If you want to go fancy, you can encapsulate attaching the adorner in an attached dependency property and just attach it to any visual you need to outline.

If you don't want to bother with adorners, you could have two separate templates for you visual - one with the outline pre-created and one without and switch them as needed. However, this requires you to know upfront what cvisuals you would need to outline and what is their style. Granted, you can make it quite flexible with data binding, but still it's not a generic solution to your problem.

Franci Penov