Reputation: 16705
I have a C#/XAML Windows Phone 8 App. In it, I'm trying to display an image on top of the screen; however, when I do so, it doesn't appear.
Here's my image:
<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>
This is part of an animation (here's the storyboard):
<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"/>
And I trigger the animation like this:
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();
I know this works, because if I replace the image with a button, it does what I expect. Why doesn't the image display? Is an image even the right control to use in this circumstance?
Upvotes: 0
Views: 2763
Reputation: 10620
You cannot use on Windows Phone 8 for Image Source the URI scheme ms-appx, it works only in Windows 8 projects.
You can check my blog article here, how to properly link images in resources/isolated storage using Uri:
Image path databinding in WP8 and Windows 8 apps
Upvotes: 4