How to customize the text of a CompletionItem?

SyntaxEditor for WPF Forum

Posted 3 years ago by IneedHelp
Version: 16.1.0633
Avatar

Currently the CompletionItem allows only a string for the content of a CompletionItem.

My question is, would it be possible to change it so that it accepts any kind of visual content?

In my case, I want to use a custom textbox that allows me to format and stylize the text to match it with the way it is displayed in the syntax editor.
Here's an example: http://i.imgur.com/h502xGG.png

Or at least is there a way to format/stylize the CompletionItem text?

[Modified 3 years ago]

Comments (6)

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

If you make an implicit Style in your App.Resource that targets IntelliPromptCompletionList, you can set the ItemListItemTemplate to any custom DataTemplate you want.  The data item passed to the list item is of type ICompletionItem.


Actipro Software Support

Posted 3 years ago by IneedHelp
Avatar

Hello. Thank you for the answer. Unfortunately I have little experience with editing resources and I do not know how to start making the modifications you suggested. If you could provide an example, I would appreciate it a lot. I am trying real hard to make the completion list look like the one in visual studio, and formatting the text is all I am missing. Thank you!

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Sorry but I'm not quite sure what you mean since our completion list is meant to mostly mimic how the Visual Studio one works.  What specifically are you trying to do?  A link to a screenshot showing the difference might be helpful.


Actipro Software Support

Posted 3 years ago by IneedHelp
Avatar

In the screenshot I have linked in the proginal post ( http://i.imgur.com/h502xGG.png ) you can see that the completion list items are coloured (in the example screenshot they are yellow and blue). That is what I am trying to accomplish- to change the style of the completion list item text.

Answer - Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

I don't believe normal VS does that sort of text highlighting for certain items.  You must have some add-on in VS that adds it.

Anyhow this is probably what you need in your app's Resources to modify the item template:

<Style TargetType="editors:IntelliPromptCompletionList">
	<Setter Property="ItemListItemTemplate">
		<Setter.Value>
			<DataTemplate DataType="editorIntelliPrompt:ICompletionItem">
				<DataTemplate.Resources>

					<editorIntelliPrompt:ImageSourceProviderConverter x:Key="ImageSourceProviderConverter" />

				</DataTemplate.Resources>

				<DockPanel>
					<Image DockPanel.Dock="Left" Width="16" Height="16" VerticalAlignment="Center"
						   Source="{Binding Path=ImageSourceProvider, Converter={StaticResource ImageSourceProviderConverter}}" />
					<shared:PixelSnapper Margin="5,0,5,0" VerticalRoundMode="CeilingToEven" VerticalAlignment="Center">
						<editorPrimitives:IntelliPromptCompletionItemText Item="{Binding}" VerticalAlignment="Center" />
					</shared:PixelSnapper>
				</DockPanel>
			</DataTemplate>
		</Setter.Value>
	</Setter>
</Style>

You'd probably have to replace our IntelliPromptCompletionItemText control with some control of your own that would switch foregrounds based on the bound ICompletionItem.


Actipro Software Support

Posted 3 years ago by IneedHelp
Avatar

This worked perfectly. Thank you very much!

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.