Change "completionsession. Items" when "completionsession" is open

SyntaxEditor for WPF Forum

Posted 8 months ago by SPF - Appeon
Version: 22.1.0
Avatar

How to update the value of "completionsession. Items" when "completionsession" is open. I need to dynamically change the value of items when entering each character, and ensure the correct behavior of the control.

Comments (3)

Posted 8 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Can you provide more detail on what you are trying to do?  Are you trying to continue showing the same items but with different text, or are you filtering down the items displayed, or something completely different?


Actipro Software Support

Posted 8 months ago by SPF - Appeon
Avatar

For example, there is no "margin: 0" data when entering M. you need to continue adding to "session. Items" when entering 0.

This type needs to input each letter to request new data, and the data will be different from the previous one, but I don't want to close the "session" How such requirements should be realized.

https://ibb.co/48Tc8kC

[Modified 8 months ago]

Posted 8 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

I believe that in WPF, you could probably do something like this to modify the Items collection live within the session while it is open:

using (var batch = this.Items.CreateBatch()) {
	this.Items.Clear();
	this.Items.Add(new CompletionItem("aaaa", null));
	this.Items.Add(new CompletionItem("bb", null));
	this.Items.Add(new CompletionItem("ccc", null));
}

You could be more selective about what you add/remove of course in your own scenario.  That code example simply shows replacing the entire list.

You'd need a custom CompletionSession-inheriting class to do this and would probably need to override its OnDocumentTextChanged method to add your Items-altering logic, then call the base implementation of the method.  You'd create an instance of your custom CompletionSession class in your completion provider service's RequestSession method.


Actipro Software Support

The latest build of this product (v22.1.3) was released 20 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.