C# 具有故事板的图像的双重动画。TargetProperty=";高度“;

C# 具有故事板的图像的双重动画。TargetProperty=";高度“;,c#,xaml,windows-phone,windows-phone-8.1,C#,Xaml,Windows Phone,Windows Phone 8.1,我已经阅读并尝试使用双动画更改图像的高度,但它不起作用 <Image Name="image" Height="100" Source="http://www.online-image-editor.com/styles/2013/images/example_image.png" Stretch="None"> <Image.Resources> <Storyboard x:Name="show">

我已经阅读并尝试使用
双动画更改图像的高度,但它不起作用

<Image Name="image" Height="100" Source="http://www.online-image-editor.com/styles/2013/images/example_image.png" Stretch="None">
        <Image.Resources>
            <Storyboard x:Name="show">
                <DoubleAnimation
                    Storyboard.TargetName="image"
                    Storyboard.TargetProperty="Height"
                     From="100" To="400" Duration="0:0:1"
                    />
            </Storyboard>
        </Image.Resources>
    </Image>
    <Button Content="image stretch" Click="button_clicked" />

[编辑]:因为Johan Falk的回答,我在Windows Phone Silverlight工具包中尝试了上述代码,结果很有效。因此,解决方案是使用Windows Phone Silverlight。

您的代码中有一个小错误,通过设置
Stretch=“None”
您不允许图像向任何方向拉伸,因此始终保持其原始大小。将
Stretch
更改为例如
Uniform
,它应该可以工作

下面是我用来验证它的示例代码:

<StackPanel x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <Image Source="/Assets/ApplicationIcon.png" x:Name="testImage" Stretch="Uniform">
        <Image.Resources>
            <Storyboard x:Name="Animation">
                <DoubleAnimation Storyboard.TargetName="testImage" Storyboard.TargetProperty="Height" From="100" To="200" Duration="0:0:1" />
            </Storyboard>
        </Image.Resources>
    </Image>
    <Button Content="Expand image" Grid.Row="1" Click="Button_Click"></Button>
</StackPanel>

我想使用Stretch=“None”,这样就不会看到整个图像。尝试了您的解决方案,即使我设置了Stretch=“uniform”,它也不起作用。您使用的是Windows Phone工具包还是Windows Phone Silverlight?我使用的是Windows Phone Silverlight。如果您只想“隐藏”图像的一部分,而不想在更改高度时拉伸图像,请将图像放置在StackPanel中,并设置StackPanel高度的动画