簡體   English   中英

如何在 Visual Studio 中尋址/調用我的自定義工具 window

[英]How to adress/ call my custom tool window in Visual Studio

通過這個簡單的 MSDN 教程,我構建了自己的 CustomToolWindow。 但是我找不到任何方法來填充它,因為我找不到引用它的方法。

目標是將它與我能夠構建 CustomDebuggerVisualizer 的本教程結合起來。 這意味着我希望我的 CustomDebuggerVisualizer 顯示為我的 CustomToolWindow 的內容。

我知道這個方法,但我也不能引用它,我認為你不能從擴展本身之外調用它。

在我看來,我沒有掌握我習慣的“運行時世界”,以及這里的“Visual Studio 擴展/SDK”世界。

但是我找不到任何方法來填充它,因為我找不到引用它的方法。

我檢查了您在上面共享的 totorial 鏈接並找到了這個文檔: Writing A Custom Debugger Visualizer using WPF for the UI So it seems that we can combine the Debugger Visualizer with WPF, and since the custom Tool window Item has similar functions like WPF UI, I think we can fill the logic into that xx.xaml and xx.xaml.cs files, see:

在此處輸入圖像描述

基本上,我們可以用我們可能在Debugger Vusualizer+WPF中使用的邏輯來填充這兩個文件。 要調用一個自定義工具窗口,我們可以單擊相關命令(按鈕)或使用代碼打開自定義工具 window。 類似於這個問題的東西:

            ToolWindowPane window = this.FindToolWindow(typeof(MyToolWindow), 0, true);
            if ((null == window) || (null == window.Frame))
            {
                throw new NotSupportedException(Resources.CanNotCreateWindow);
            }
            IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());

我不確定您為什么需要以編程方式調用自定義 window,根據教程,我想您只需要View=>Windows中的一個按鈕 ...希望它有所幫助,如果我有什么誤解,請隨時糾正我:)

我試圖想象我掙扎的地方。

可視化

編輯:取得了進展:

當一個在 vsix 擴展 package 內部時,可以通過查詢 dte object

using EnvDTE;
using EnvDTE80;  
using System.ComponentModel.Composition; 

DTE2 dte = (DTE2)ServiceProvider.GlobalProvider.GetService(typeof(DTE));

有了這個,可以訪問保存各種信息的調試器,例如在這種情況下它保存當前活動的字段等等。

因此,這是將數據從運行時傳輸到 ToolWindow 的方法。 問題是如何將 DebugVisualizer 帶入等式,因為它不是 package 的一部分,因此無法調用 dte。 但我很在意。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM