Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

Custom Tool: Hosting an editor (IWpfTextViewHost) in a tool window

$
0
0

I'm trying to host a IWpfTextView within a custom tool window. My project is facing the exact same issue as this one: http://social.msdn.microsoft.com/Forums/en/vsxprerelease/thread/5baa6ad8-9730-4e20-b93e-1b88a8ff1cf4

 

I'm trying to create a IWpfTextView and then put it into a custom tool window. I can create the view, read a file to populate the ITextBuffer and display the view into my tool.

I cannot edit the code at all, the code is not syntax highlighted and I do not get a context menu on right-click. What steps am I missing to make this a full fledged editor?

Here is my code:

 

    IComponentModel componentModel =(IComponentModel)GetGlobalService(typeof(SComponentModel));
   
var _textEditorFactoryService = componentModel.GetService<ITextEditorFactoryService>();
   
var _textBufferFactoryService = componentModel.GetService<ITextBufferFactoryService>();
   
var _contentTypeRegistryService = componentModel.GetService<IContentTypeRegistryService>();

   
TextReader reader =newStreamReader(fileName);

   
var types = _contentTypeRegistryService.GetContentType("CSharp");

   
ITextBuffer textBuffer = _textBufferFactoryService.CreateTextBuffer(reader, types);
   
var view = _textEditorFactoryService.CreateTextView(textBuffer);

   
IWpfTextViewHost editor = _textEditorFactoryService.CreateTextViewHost(view,true);

 

I'm using Visual Studio 2010 RC, C# 

 


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>