Firoz
Firoz

Reputation: 7454

How to apply multiple effect on same element

How can i set mulitple effect like(shadow and blur) on same element.

Upvotes: 13

Views: 8985

Answers (4)

Yaron Binder
Yaron Binder

Reputation: 125

For me I found using style along side <Element.Effect> is great!

For example:

<Border>
    <Border.Effect>
        <DropShadowEffect BlurRadius="3" ShadowDepth="3" Direction="315" Color="#CAA"/>
    </Border.Effect>
    <Border.Style> 
        <Style TargetType="{x:Type Border}">
            <Setter Property="Effect">
                <Setter.Value>
                    <DropShadowEffect BlurRadius="5" ShadowDepth="0" Color="#FDD"/>
                </Setter.Value>
            </Setter>                                       
         </Style>
    </Border.Style>
</Border>

It could work with BlueEffect as well, but there is a limit of only two effects per element.

Upvotes: 0

David Hollinshead
David Hollinshead

Reputation: 1790

See Using Effects in WPF (Part 2) by Greg Schechter where one can simply nest Decorators like a Border and put a different Effects on each.

Upvotes: 12

Ashok Gowtham
Ashok Gowtham

Reputation: 67

To build on the initial answer and provide an example, just enclose the UIElement within another new UIElement (any element for that matter, like a stack panel for example).

Then apply effects for both elements as such:

<StackPanel>
    <MediaElement Name="myMedia" Source="Fairytale Dream.wmv" >
        <MediaElement.Effect>
            <ShaderEffectLibrary:BloomEffect />
        </MediaElement.Effect>
    </MediaElement>
    <StackPanel.Effect>
        <ShaderEffectLibrary:ZoomBlurEffect />
    </StackPanel.Effect>
</StackPanel>

Upvotes: 5

Sasikumar D.R.
Sasikumar D.R.

Reputation: 862

I think there is no need to combine effects here.

One of these effect will help you for simulating other effects like in case of DropShadow Effect, You could use BlurRadius for Blur Effect and ShadowDepth for shadow..

By using appropriate values you could simulate combination effects...

Upvotes: -7

Related Questions