相关疑难解决方法(0)

在VS 2010 RC扩展中查找给定ProjectItem的IVsTextView或IWpfTextView

我有ProjectItem,并希望获得与之关联的IWPFTextView(如果有).

我试图获取一个IVsTextManager,然后遍历视图,但iVsTextManager.EnumViews总是不返回任何内容.

这是我到目前为止所得到的:

var txtMgr = (IVsTextManager)Package.GetGlobalService(typeof(SVsTextManager));

if (txtMgr != null)
{
    IVsEnumTextViews iVsEnumTextViews;
    IVsTextView[] views = null;

    // Passing null will return all available views, at least according to the documentation
    // unfortunately, this returns a 0x80070057 error (invalid parameter)
    var errorValue = txtMgr.EnumViews(null, out iVsEnumTextViews);

    if (errorValue == VSConstants.S_OK)
    {
        // enumerate, find the IVsTextView with a matching filename.
Run Code Online (Sandbox Code Playgroud)

当然还有另一种/更好的方法吗?

提前致谢

〜卡梅伦

add-in visual-studio-2010

13
推荐指数
2
解决办法
4058
查看次数

标签 统计

add-in ×1

visual-studio-2010 ×1