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.
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.
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?
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.
[Modified 3 years ago]
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.
Please log in to a validated account to post comments.