我有一个 C#/XAML Windows Phone 8 应用程序。在其中,我试图在屏幕顶部显示图像;但是,当我这样做时,它不会出现。
这是我的图像:
<Image Grid.Row ="1" Grid.RowSpan="4" Grid.Column ="1"
Width ="150" Height ="100"
Visibility ="Collapsed" x : Name="MyImage">
<Image.RenderTransform>
<ScaleTransform CenterX ="75" CenterY="50">
</ScaleTransform>
</Image.RenderTransform>
</Image>
这是动画的一部分(这里是故事板):
<DoubleAnimation Storyboard.TargetName ="MyImage"
Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)"
From ="0" To ="1" Duration="0:0:0.2"/>
<DoubleAnimation Storyboard.TargetName ="MyImage"
Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)"
From ="0" To ="1" Duration="0:0:0.2"/>
我像这样触发动画:
BitmapImage newImage = new BitmapImage ();
newImage.UriSource = new Uri( "ms-appx:///Assets/MyImage.png" ); // Can change
MyImage.Source = newImage;
MyImage.Visibility = Visibility .Visible;
Storyboard sbExpand = (Storyboard )this.Resources[storyboardName];
sbExpand.Completed += sbExpand_Completed;
sbExpand.Begin();
我知道这行得通,因为如果我用按钮替换图像,它会达到我的预期。为什么图像不显示?在这种情况下,图像甚至是正确的控件吗?