我有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)
当然还有另一种/更好的方法吗?
提前致谢
〜卡梅伦