Find an IVsTextView or IWpfTextView for a given ProjectItem, in VS 2010 RC extension

前端 未结 3 1836
一向
一向 2020-12-05 19:46

I have the ProjectItem, and want to get the IWPFTextView that is associated with it, if any.

I have tried to get an IVsTextManager, and then iterate through the view

3条回答
  •  忘掉有多难
    2020-12-05 20:29

    You can get IWpfTextView like that:

    var componentModel = (IComponentModel)GetService(typeof(SComponentModel));
    var textManager = (IVsTextManager)Package.GetGlobalService(typeof(SVsTextManager));
    IVsTextView activeView = null;
    ErrorHandler.ThrowOnFailure(textManager.GetActiveView(1, null, out activeView));
    var editorAdapter = componentModel.GetService();
    IWpfTextView wpfTextView = editorAdapetr.GetWpfTextView(activeView);
    

提交回复
热议问题