Home » Windows OSRSS

removing inherited effects, or routing events from one control to another.

Hi I'm not sure if this is the proper thread to put this question, but I'll give it a go anyway.

I have a SurfaceListBox with a control template that uses Effect.DropShadowEffect on it’s border. Some of the content is a third party control, that gets too much overhead using this effect. What I want is to only have this effect on the border of the listbox, and not it’s content. I’ve tried to set the BlurRadius etc to 0, but it doesn’t help on the performance.

Is there really no way to completely remove the inherited effects in WPF?

My hack solution to the problem was to pull the border out of the controltemplate, and then just drawing the listbox on top of it. This doesn’t look so good, as the content will not appear to be under the borders shadow. Which brings me to question number two, is there an elegant way to route events from my border/control to the listbox if I place it under the border/control? To be specific my listbox implements a surfacescrollviewer with a panel, and I want the listbox to receive drop, touchdown, touchmove and etc events.

Best regards,

Stian Farstad

 

1 Answer Found

 

Answer 1

Hi 

Use the FrameworkPropertyMetadata.Inherits Property as shown bellow

 

PropertyMetadata propertyMetaData = EffectProperty.GetMetadata(border1);

            FrameworkPropertyMetadata fmMetadata = propertyMetaData as FrameworkPropertyMetadata;

            fmMetadata.Inherits = false;

All that you need is to render the effect  property of the given border  not inheritable by its childs. Of Corse you put  the right name of the border instead of the border1

 

 


The complexity resides in the simplicity
 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter