C# 本地位图图像(windows phone)

C# 本地位图图像(windows phone),c#,windows-phone,C#,Windows Phone,我试图传达的路径,但当我运行应用程序时,不会显示图像 FlagImage.Source = new BitmapImage(new Uri("/images/sky.jpg")); 如果更改URL的路径,将显示图像 FlagImage.Source = new BitmapImage(new Uri("http://www.charlespetzold.com/Media/HelloWP7.jpg")); 此代码也可以工作: <Image Source="/images/sky.jpg

我试图传达
的路径,但当我运行应用程序时,不会显示图像

FlagImage.Source = new BitmapImage(new Uri("/images/sky.jpg"));
如果更改URL的路径,将显示图像

FlagImage.Source = new BitmapImage(new Uri("http://www.charlespetzold.com/Media/HelloWP7.jpg"));
此代码也可以工作:

<Image Source="/images/sky.jpg"/>

您已经通过将bitmapimage URI源的路径设置为相对..来初始化它,如下所示

  FlagImage.Source = new BitmapImage(new Uri("/images/sky.jpg", UriKind.Relative));

希望它能帮助你。

我理解。有必要添加UriKind.Relative

FlagImage.Source = new BitmapImage(new Uri("/images/sky.jpg", UriKind.Relative));

您必须设置图像的相对来源,如答案中所示。。