【发布时间】:2015-11-25 11:11:50
【问题描述】:
我是 VS 扩展开发的新手。我目前正在使用 VS 2015 中的文本装饰示例,并且能够正确显示彩色框。现在我想扩展示例,使装饰只出现在某些文件名上。
谷歌搜索说我可以使用ITextDocumentFactoryService.TryGetTextDocument 接口和IWpfTextView.TextBuffer 属性来获取文件名。这听起来很棒。但我似乎无法真正获得界面。
在我的课堂上我有:
[Import]
public ITextDocumentFactoryService TextDocumentFactoryService = null;
但它始终为 NULL。
我怎样才能得到ITextDocumentFactoryService?
namespace Test
{
internal sealed class TestAdornment
{
[Import]
public ITextDocumentFactoryService TextDocumentFactoryService = null;
public TestAdornment(IWpfTextView view)
{
}
/// <summary>
/// Adds the scarlet box behind the 'a' characters within the given line
/// </summary>
/// <param name="line">Line to add the adornments</param>
private void CreateVisuals(ITextViewLine line)
{
// TextDocumentFactoryService is NULL
}
}
}
【问题讨论】: