如何:对斜切可视化效果进行动画处理

更新:2007 年 11 月

本示例演示如何对按钮上的 BevelBitmapEffect 进行动画处理。

示例

下面的示例演示如何对 BevelBitmapEffectBevelWidthLightAngle 属性进行动画处理。因此,当鼠标指针移到 Button 上时,楔形的内部级别增加,同时用于楔形的人造光源将围绕着 Button 旋转。

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

  <StackPanel>

    <Button Width="200" Height="80" Margin="50">
      MouseOver ME!
      <Button.BitmapEffect>

        <!-- This BitmapEffect is targeted by the animation. -->
        <BevelBitmapEffect x:Name="myBevelBitmapEffect" BevelWidth="0" EdgeProfile="CurvedIn"  />
      </Button.BitmapEffect>
      <Button.Triggers>
        <EventTrigger RoutedEvent="Button.MouseEnter">
          <BeginStoryboard>
            <Storyboard>

              <!-- Animate the BevelWidth from 0 to 15. -->
              <DoubleAnimation
               Storyboard.TargetName="myBevelBitmapEffect"
               Storyboard.TargetProperty="BevelWidth"
               From="0" To="15" Duration="0:0:0.5" AutoReverse="True"
               />

              <!-- Animate the LightAngle so that the light source and 
                   corresponding bevel shadows move around the button. -->
              <DoubleAnimation
               Storyboard.TargetName="myBevelBitmapEffect"
               Storyboard.TargetProperty="LightAngle"
               From="360" To="0" Duration="0:0:0.5" AutoReverse="True"
               />
            </Storyboard>
          </BeginStoryboard>
        </EventTrigger>
      </Button.Triggers>
    </Button>

  </StackPanel>

</Page>

有关完整示例,请参见 位图效果库示例

请参见

任务

如何:创建斜切可视化效果

如何:对多个可视化效果进行动画处理

位图效果库示例

概念

位图效果概述

其他资源

位图效果帮助主题

位图效果示例