다음을 통해 공유


방법: 그림자 시각 효과에 애니메이션 적용

업데이트: 2007년 11월

다음 예제에서는 DropShadowBitmapEffectShadowDepthSoftness에 애니메이션 효과를 적용하여 Button을 클릭했을 때 화면에서 올라오는 것처럼 보이게 만드는 방법을 보여 줍니다.

예제

<Page xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml" >

  <StackPanel>

    <Button Margin="50" Width="200" Name="myButton">
      Click Me to Animate Drop Shadow!
      <Button.BitmapEffect>

        <!-- This BitmapEffect is targeted by the animation. -->
        <DropShadowBitmapEffect x:Name="myDropShadowBitmapEffect" Color="Black"   
         ShadowDepth="0" />
      </Button.BitmapEffect>
      <Button.Triggers>
        <EventTrigger RoutedEvent="Button.Click">
          <BeginStoryboard>
            <Storyboard>

              <!-- Animate the movement of the button. -->
              <ThicknessAnimation
               Storyboard.TargetProperty="Margin" Duration="0:0:0.5" 
               From="50,50,50,50" To="0,0,50,50" AutoReverse="True" />

              <!-- Animate shadow depth of the effect. -->
              <DoubleAnimation
               Storyboard.TargetName="myDropShadowBitmapEffect"
               Storyboard.TargetProperty="ShadowDepth"
               From="0" To="30" Duration="0:0:0.5"
               AutoReverse="True" />

              <!-- Animate shadow softness of the effect. As 
                   the Button appears to get farther from the shadow,  
                   the shadow gets softer. -->
              <DoubleAnimation
               Storyboard.TargetName="myDropShadowBitmapEffect"
               Storyboard.TargetProperty="Softness"
               From="0" To="1" Duration="0:0:0.5"
               AutoReverse="True" />
            </Storyboard>
          </BeginStoryboard>
        </EventTrigger>
      </Button.Triggers>
    </Button>

  </StackPanel>

</Page>

참고 항목

작업

방법: 그림자 시각 효과 만들기

방법: 글로우 효과에 애니메이션 효과 주기

방법: 흐림 시각 효과에 애니메이션 효과 적용

방법: 여러 시각 효과에 애니메이션 적용