1

这是我的 XAML:

<Setter Property="Template">
  <Setter.Value>
    <ControlTemplate>
      <Image x:Name="Expander_Normal"
             Source="/Images/arrow-e.tiff" Width="13" Height="13" />
      <ControlTemplate.Triggers>
        <Trigger Property="ToggleButton.IsChecked" Value="True">
          <Setter x:Name="Expander_Expanded"
                  TargetName="Expander_Normal" Property="Source"
                  Value="/Images/arrow-s.tiff" />
        </Trigger>
      </ControlTemplate.Triggers>
    </ControlTemplate>
  </Setter.Value>
</Setter>

从图像到另一个图像的过渡非常粗糙,我不太喜欢它。那么如何才能使过渡平滑。
更新:
也许不是更改图像,而是旋转图像。主图像看起来像 >。所以也许把它向下旋转(顺时针90度)

4

2 回答 2

2

如果你想花哨,你可以:

  1. 添加故事板
  2. 在不透明度上使用双动画淡出图像框
  3. 更改图像
  4. 使用另一个双重动画淡入图像框

更新

要旋转图像:

  1. 向图像添加旋转变换
  2. 在旋转变换的角度属性上使用双重动画

有关示例,请参见http://www.vbforums.com/showthread.php?t=555120

于 2010-02-06T01:33:28.843 回答
0

试试这个:

<Grid>
    <Image Source="Image1.png"
           Height="100" Width="100">
        <Image.Triggers>
            <EventTrigger RoutedEvent="MouseEnter">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation
                            BeginTime="0:0:0"
                            Duration="0:0:0.5"
                            From="1"
                            To="0"
                            Storyboard.TargetProperty="(Image.Opacity)"
                            />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
            <EventTrigger RoutedEvent="MouseLeave">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation
                            BeginTime="0:0:0"
                            Duration="0:0:0.8"
                            From="0"
                            To="1"
                            Storyboard.TargetProperty="(Image.Opacity)"/>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Image.Triggers>
    </Image>
    <Image Source="Image2.png"
           Height="100" Width="100" Opacity="0">
        <Image.Triggers>
            <EventTrigger RoutedEvent="MouseEnter">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation
                            BeginTime="0:0:0"
                            Duration="0:0:0.5"
                            From="0"
                            To="1"
                            Storyboard.TargetProperty="(Image.Opacity)"
                            />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
            <EventTrigger RoutedEvent="MouseLeave">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation
                            BeginTime="0:0:0"
                            Duration="0:0:0.8"
                            From="1"
                            To="0"
                            Storyboard.TargetProperty="(Image.Opacity)"/>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Image.Triggers>
    </Image>
</Grid>
于 2016-08-03T01:24:19.603 回答