我正在编写我的第一个 VS 扩展。 到目前为止,我有代码来获取选定的文本并显示消息框或操作选择:
扩展的 CTOR..
private StringRefactor(Package package)
{
if (package == null)
{
throw new ArgumentNullException("package");
}
this.package = package;
OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (commandService != null)
{
var menuCommandID = new CommandID(CommandSet, CommandId);
var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandID);
commandService.AddCommand(menuItem);
}
}
回调:
private void MenuItemCallback(object sender, EventArgs e)
{
var selection = getSelection();
var selectedText = selection == null ? "No text selected..." : selection.StreamSelectionSpan.GetText();
string message = string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()", this.GetType().FullName);
string title = "StringRefactor";
// Show a message box to prove we were here
VsShellUtilities.ShowMessageBox(
this.ServiceProvider,
selectedText,
title,
OLEMSGICON.OLEMSGICON_INFO,
OLEMSGBUTTON.OLEMSGBUTTON_OK,
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
}
现在我想打开一个显示多个文本框和确定\取消按钮的提示窗口,而不是 VsShellUtilities.ShowMessageBox(...
..
我想创建另一个 WPF 应用程序项目并从回调中启动它,但我不确定这是编写打开自定义工具的扩展的正确方法..
那么打开具有 VISIX 功能的自定义窗口的正确方法是什么?
最佳答案
您可以在 VSIX 扩展中创建自己的 WPF 对话框。事实上,Visual Studio 就是为此而设计的(因为 UI 是 WPF)。
有关进一步说明,请参阅本文:
关于c# - 打开一个 WPF 窗口应用程序窗体 VS 扩展命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36886701/