views:

16

answers:

1

I was wondering if there was a way to make a template for an effect so I can apply it to all my controls. That way if i was the effect to be modified, I only have to change it in one location...

Let's say I have:

<Button Content="Foo" Height="50" Width="50" >
   <Button.Effect>
      <DropShadowEffect BlurRadius="10" Color="Black" Opacity="0.5" ShadowDepth="0"/>
   </Button.Effect>
</Button>

I would like to have (I know it's not correct):

<UserControl.Resources>
   <Effect x:Key="MyEffect">
      <DropShadowEffect BlurRadius="10" Color="Black" Opacity="0.5" ShadowDepth="0"/>
   </Effect>
</UserControl.Resources>

...

<Button Content="Foo" Height="50" Width="50" Effect="{StaticResource MyEffect}" />

Is there a way to do something like this ?

+1  A: 

Just give a key to DropShadowEffect

<UserControl.Resources>
    <DropShadowEffect x:Key="MyEffect" BlurRadius="10" Color="Black" Opacity="0.5" ShadowDepth="0"/>   
</UserControl.Resources>
Stephan
Thanks very much!
gmcalab