Wpf WinRT:Image-Image不';如果未作为资源包含,则不会显示

Wpf WinRT:Image-Image不';如果未作为资源包含,则不会显示,wpf,xaml,data-binding,windows-runtime,winrt-xaml,Wpf,Xaml,Data Binding,Windows Runtime,Winrt Xaml,我的Windows应用商店应用程序/Metro/Win RT应用程序将图像从服务器下载到某个本地文件夹。我需要在运行时将映像控件绑定到下载的映像 问题是,除非我将图像作为二进制资源添加到项目中,否则图像不会显示。 我下载的图像存储在ProjectFolder/Data/Media中。现在,我将如何将图像源绑定到图像控件 <Image x:Name="WriterImage" Stretch="None" Source="{Binding Path=PersonData.Photo.Med

我的Windows应用商店应用程序/Metro/Win RT应用程序将图像从服务器下载到某个本地文件夹。我需要在运行时将映像控件绑定到下载的映像

问题是,除非我将图像作为二进制资源添加到项目中,否则图像不会显示。

我下载的图像存储在ProjectFolder/Data/Media中。现在,我将如何将图像源绑定到图像控件

<Image x:Name="WriterImage"  Stretch="None" Source="{Binding Path=PersonData.Photo.MediaImageSource"></Image>

public ImageSource MediaImageSource
{
    // Here _MediaUrl gets a value: ms-appx:///Data/Media/Writer1.jpg   
    BitmapImage source = new BitmapImage(new Uri(_MediaUrl));

} 

公共图像源MediaImageSource
{
//这里_MediaUrl获取一个值:ms-appx:///Data/Media/Writer1.jpg   
BitmapImage源=新的BitmapImage(新Uri(_MediaUrl));
} 

仅当我将Writer1.jpg作为资源添加到项目中时,这才有效。如果我将其从项目中删除,它将不会显示。

请注意,应用程序可以访问不同的URL方案:

ms-appx://
是一个只读位置,指的是应用程序中包含(编译)的文件,如资源

ms-appdata:///local/
指应用程序的本地读写存储。如果您正在下载文件,我猜您应该使用此URL方案

对于上面的示例,我将尝试使用以下URL:

ms-appdata:///local/Data/Media/Writer1.jpg

有关URL(URI)方案的更多信息,请参见以下内容: