我正在尝试将一个简单的 WPF 程序移植到 UWP。它是一种将一些自定义图像分析例程应用于一堆图像的工具。
基本功能:
- 将图像添加到图库视图(可能是 100,000 张图像)
- 对图像进行分析
- 导出数据
我遇到的问题是在画廊中显示图像。
在 WPF 中,我可以ListBox绑定到类似ObservableCollection的InputImage<Image Source={Binding Image, IsAsync=True} />
public class InputImage
{
public string Path { get; set; }
public BitmapImage Source
{
get
{
var image = new BitmapImage(new Uri(Path, UriKind.Absolute));
image.Freeze();
return image;
}
}
}
UWP 中的等价物是什么?
- 我已经尝试了上述方法(减去
IsAsync和Freeze部分),但图像的宽度和高度为 0。 - 我想也许我必须
StorageFile从路径创建一个,打开它并设置位图源,但我不能使用async属性 getter 中的方法......
有什么解决办法吗?
注意:我在 appxmanifest 中启用了 broadFileSystemAccess" 并在 Settings -> Privacy -> File System 中为应用打开了