2014-08-29 115 views
0

我已經爲WPF中的visual studio 2010創建了一個插件。一切看起來都很好,除了停靠時,標籤名稱消失。請參閱下面的截圖。Visual Studio 2010 WPF Addin不顯示標籤名稱正確

Addin Screenshot

我發現在MSDN論壇上闡明下面的內容

  1. 獲取使用IVsUIShell.GetToolWindowEnum相應IVsWindowFrame爲mWindow()。
  2. 調用IVsWindowFrame.SetProperty((int)__ VSFPROPID.VSFPROPID_Caption,「my caption」);

我已經試過這樣做,但我不能得到承認,在其中找到了IVsUIShell的方法GetService的IDE。之後,情況變得更糟。

有人明白這條指令嗎?如果是的話,你能幫我到那裏嗎?這似乎是我錯過了一個參考,但其他一切看起來都很正常。

在此先感謝,克里斯

回答

0

我終於想通了。這裏是我最終使用的代碼 -

  // Get the service provider on the object 
      Microsoft.VisualStudio.Data.ServiceProvider serviceProvider = new Microsoft.VisualStudio.Data.ServiceProvider(this._applicationObject as Microsoft.VisualStudio.OLE.Interop.IServiceProvider); 

      // Get the shell service 
      var vsUIShell = (IVsUIShell)serviceProvider.GetService(typeof(SVsUIShell)); 
      Guid slotGuid = new Guid(guidString); 

      // Find the associated window frame on this toolwindow 
      IVsWindowFrame wndFrame; 
      vsUIShell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fFrameOnly, ref slotGuid, out wndFrame); 

      // Set the text on the window tab name 
      wndFrame.SetProperty((int)__VSFPROPID.VSFPROPID_Caption, "Upgraded Task List"); 

它從visual studio實例獲取服務提供者。然後,您可以使用工具窗口的GUID獲取toolwindow框架。最後,在最後一行設置工具窗口選項卡上的文本。

希望是有道理的。我花了很長時間才弄明白這一點。