如何在 VSIX 对话框页面中创建文件选择器选项?

How can I create a file picker option in a VSIX DialogPage?

我正在为 Visual Studio 2017 创建一个扩展。我需要一个 select 目录的选项。我创建了一个带有字符串选项的 DialogPage,如 https://msdn.microsoft.com/en-us/library/bb166195.aspx 中所示。它运行良好但不是真正的用户友好。 我想用文件选取器替换它,但不知道如何在 DialogPage 中执行此操作。我该怎么做?

If you want to host a user-created control inside an options page, it could be achieved by overriding the Window property of your DialogPage subclass:

[BrowsableAttribute(false)] 
protected override IWin32Window Window { 
get { return MyUserControl; } 
}

A reference to the IWin32Window object implementing the window's client area should be returned by this property. Visual Studio requires its options pages to be constant, i.e. they should not be recreated for any of their subsequent calls. As Windows Forms objects can delete and recreate their window handles at will, we recommend passing a reference to the object derived from a UserControl type.

然后根据它是 WPF 还是 Winform 创建一个带有更好的文件选择器 GUI 的用户控件,例如 returns IWin32Window 实现的 OpenFileDialog 控件。

See the Ref