I'm developing a Windows Phone app.
I'm using an image and when I select a picture using Properties panel I get the following XAML:
<Image x:Name="GameImage" Margin="8" Source="/MyApp;component/Assets/Icons/GameImage.png"/>
Why am I getting "/MyApp;component/...
"? (Is there any better way?)
If I try to do Image.Source="Assets/Icons/GameImage.png"
why does it not work?
This is because your image has it's build action set to Resource (Which is the default). If you switch it to Content you can set the source in your XAML like this:
<Image x:Name="GameImage" Margin="8" Source="/Assets/Icons/GameImage.png"/>
To set it in code you can do this:
BitmapImage tn = new BitmapImage();
tn.SetSource(Application.GetResourceStream(new Uri(@"Assets/Icons/GameImage.png", UriKind.Relative)).Stream);
Image.Source = tn;
You should be using Content for performance reasons. See this article for more detail: http://www.windowsphonegeek.com/tips/wp7-working-with-images-content-vs-resource-build-action