WinRT 中用于显示图片的路径 (ImageSource) 保存在图片文件夹中(不在应用程序包中)
The path (ImageSource) in WinRT to display an image that is saved in Pictures folder (not in app packages)
所以,我已经将图片保存在
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 schemes 可用于图片库。
您通常不会将 URI 硬编码到 XAML 中的图片库文件,因为您不能依赖该文件。
如果您按路径将文件列表存储在某处,您仍然需要使用一些代码加载它们 - 可能使用未来的访问列表、打开文件流等。
您可能会创建一个 IValueConverter
或附加行为/DependencyProperty
以将字符串转换为 ImageSource
,但您也可以在视图模型中执行此操作。
所以,我已经将图片保存在
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 schemes 可用于图片库。
您通常不会将 URI 硬编码到 XAML 中的图片库文件,因为您不能依赖该文件。
如果您按路径将文件列表存储在某处,您仍然需要使用一些代码加载它们 - 可能使用未来的访问列表、打开文件流等。
您可能会创建一个 IValueConverter
或附加行为/DependencyProperty
以将字符串转换为 ImageSource
,但您也可以在视图模型中执行此操作。