Xaml WinRT中显示保存在Pictures文件夹(非应用程序包)中的图像的路径(ImageSource)

Xaml WinRT中显示保存在Pictures文件夹(非应用程序包)中的图像的路径(ImageSource),xaml,windows-runtime,winrt-xaml,Xaml,Windows Runtime,Winrt Xaml,因此,我已将我的图像保存在 StorageFile picture = await KnownFolders.PicturesLibrary.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting); 我想在XAML中显示它: <Image Grid.Row="1" Grid.Column="0" x:Name="Photo"

因此,我已将我的图像保存在

StorageFile picture = await KnownFolders.PicturesLibrary.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
我想在XAML中显示它:

 <Image  Grid.Row="1"
                Grid.Column="0"
                x:Name="Photo"
                Source="ms-appx:///Pictures/test.png"
                VerticalAlignment="Center"
                HorizontalAlignment="Left"
                Stretch="Fill"
                Width="1024"
                Height="768">
        </Image>

但它不起作用:(

非常感谢您的帮助:)

没有任何图片库可以使用

无论如何,您通常不会将URI硬编码到XAML中的图片库文件中,因为您不能依赖该文件的存在

如果您将文件列表按路径存储在某个位置,您仍然需要使用一些代码来加载它们—可能需要使用将来的访问列表、打开文件流等


您可能会创建一个
IValueConverter
或一个附加的行为/
dependencProperty
来将字符串转换为
ImageSource
,但您也可以在视图模型中这样做。

我不知道,如果ms appx:part只是被抛出到文件夹中,您是否需要它,但是,您也可以检查在该图像的属性上设置了什么构建操作。谢谢。我确实在写一个转换器。:)