In the Intellisense Presenter sample, the default UI (presenter) from Completion is replaced. Completion, the list that opens suggesting the next thing to write, is a form of Intellisense in Visual Studio. Other forms of Intellisense include: Quick Info (the tooltip when you hover over a class or a method), Signature Help (the tooltip that opens when writing a method call) and Smart Tag (the red button that can be used to automatically implement an interface). All of these have common extensibility interfaces, and all can be extended in a very standard way.

To replace the UI of an intellisense component, you must implement and export an IIntellisensePresenterProvider. The only method of this interface (TryCreateIntellisensePresenter) provides an IIntellisenseSession and expects you to return an IIntellisensePresenter. You can use the session to know which type of intellisense the session represents.

There are specific interfaces for each type of intellisense (ICompletionSession, IQuickInfoSession, ISignatureHelpSession and ISmartTagSession). To know which type of intellisense you're getting, simply cast the session to one of these interfaces and check for null.

The IIntellisensePresenter is the main class in this functionality. If you want to implement a common popup intellisense, you can implement IPopupIntellisensePresenter. If you want to provide something else (for instance, something with sound and voice) you will implement ICustomIntellisensePresenter. In the sample, we are implementing IPopupIntellisensePresenter.

The main member of IPopupIntellisensePresenter is the SurfaceElement. This is the WPF control that will be shown when the intellisense session starts. In the sample, this control is the CompletionSessionView. You will have to change the session when the completion session changes, and that's what most of the code in the sample does (and also, that's the reason we're also implementing IIntellisenseCommandTarget).

Last edited Nov 30, 2009 at 7:53 PM by joj, version 1


No comments yet.