1 回答
TA贡献1887条经验 获得超5个赞
创建一个文件:
using System;
using System.Runtime.InteropServices;
namespace <standardnamespace>
{
[ComImport]
[Guid("3E68D4BD-7135-4D10-8018-9FB6D9F33FA1")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IInitializeWithWindow
{
void Initialize(IntPtr hwnd);
}
}
将您的代码更改为:
public async void Load()
{
var picker = new FileOpenPicker()
{
SuggestedStartLocation = PickerLocationId.PicturesLibrary,
FileTypeFilter = { ".jpg", ".jpeg", ".png", ".bmp" },
};
((IInitializeWithWindow)(object)picker).Initialize(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle);
var file = await picker.PickSingleFileAsync();
if (file != null)
{
}
else
{
}
}
- 1 回答
- 0 关注
- 123 浏览
添加回答
举报