업데이트: 2007년 11월
이 예제에서는 BitmapEffectGroup 내에서 BitmapEffect에 애니메이션 효과를 적용하는 방법을 보여 줍니다.
예제
다음 예제에서는 DropShadowBitmapEffect의 Color 속성에 애니메이션 효과를 적용하는 데 사용되는 TargetProperty 경로의 두 가지 예를 보여 줍니다. MouseEnter 및 MouseLeave 이벤트 트리거는 서로 다른 경로를 사용하여 BitmapEffectGroup 내의 BitmapEffect에 액세스하는 방법을 보여 줍니다.
<Page
xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml" >
<Page.Resources>
<Style TargetType="{x:Type Button}" x:Key="MyButtonStyle">
<Setter Property="Button.BitmapEffect">
<Setter.Value>
<BitmapEffectGroup>
<DropShadowBitmapEffect x:Name="myDropShadowBitMapEffect" Color="Black" ShadowDepth="3" />
<OuterGlowBitmapEffect GlowColor="Gray"/>
<!-- BitmapEffect -->
</BitmapEffectGroup>
</Setter.Value>
</Setter>
<Style.Triggers>
<EventTrigger RoutedEvent="Button.MouseEnter">
<EventTrigger.Actions>
<BeginStoryboard >
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="(Button.BitmapEffect).(BitmapEffectGroup.Children)[0].(DropShadowBitmapEffect.Color)" From="Gray" To="Red" Duration="0:0:0.5" AutoReverse="False" />
<!-- <ColorAnimation Storyboard.TargetProperty="BitmapEffect.Children[0].Color" From="Gray" To="Red" Duration="0:0:0.5" AutoReverse="False" /> -->
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="Button.MouseLeave">
<EventTrigger.Actions>
<BeginStoryboard >
<Storyboard>
<!-- <ColorAnimation Storyboard.TargetProperty="(Button.BitmapEffect).(BitmapEffectGroup.Children)[0].(DropShadowBitmapEffect.Color)" From="Gray" To="Red" Duration="0:0:0.5" AutoReverse="False" /> -->
<ColorAnimation Storyboard.TargetProperty="BitmapEffect.Children[0].Color" From="Red" To="Gray" Duration="0:0:0.5" AutoReverse="False" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>
</Page.Resources>
<StackPanel Margin="20">
<Button Style="{StaticResource MyButtonStyle}">Click Me</Button>
</StackPanel>
</Page>