首页 > 解决方案 > Visual Studio 扩展:更改编辑器选项卡名称

问题描述

我尝试使用扩展名更改 Visual Studio 2017 中编辑器选项卡的标题。来自 DTE2 并使用 getter ActiveWindow 我可以阅读标题,但如果我更改它,则会发生“System.InvalidOperationException”异常。

var dte = Package.GetGlobalService(typeof(DTE)) as DTE2;
var currentWindows = dte.Windows;

foreach (Window window in dte.Windows)
{
    if (window.Caption.EndsWith("cs"))
        window.Caption = "foo";            
}

实现 IWpfTextViewCreationListener 我可以获得已打开文件的创建 IWpfTextView,但我无法在那里找到标题。

internal sealed class ViewportAdornment1TextViewCreationListener : IWpfTextViewCreationListener
{  
    public void TextViewCreated(IWpfTextView textView)
    {
        // Own implementation
        new ViewportAdornment1(textView);
    }
}

任何人都可以给我一个起点,我可以在哪里继续?

标签: c#visual-studiovisual-studio-extensionsvs-extensibility

解决方案


推荐阅读