This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi there, I recently used the Autocomplete textbox in a situation where I needed to enter multiple entries separated by a delimeter character, e.g. a space or comma (see attached image). To implement this, I added new dependency property to the AutoCompleteBox control, named InputDelimiter (char[]) and then modified UpdateSuggestionList. Would this be a useful feature that you would add to your code base? If so, it would be one less change that needs to merged when I take a new release.
regards, Dennis Roche |
|
|
Hello Dennis You can provide custom suggestion-list logic without modifying the UpdateSuggestionList method. Start by creating a new class that implements the IAutoCompleteSuggestionProvider. This class will need a way to get a list of all the suggestions such as a property. Then you can implement the GetSuggestions method using your custom logic. You custom logic class may also need the property for changing the deliminator chars. You can then create an instance of this class and use it to set the AutoCompleteBox.SuggestionsSource property. Take a look at the source code of the AutoCompleteListSuggestionProvider class to get an idea of how the default logic works. Let us know how it goes |
|
|
Hi Jason, .... I initially tried implementing an autocomplete suggestion provider as that appeared to be the way it was designed to be extended - however unfortunately it wasn't possible as the entire .Text value is replaced when a value is selected (either on the selection changed event or when using the keyboard). |
|
|
Hello Dennis Sorry I missunderstood your original post. I was thinking of each entry being a search option for the suggestion list, rather then each entry being an individual item added to the AutoCompleteBox. I think this is an excellent feature and so I have implemented this. By downloading the nightly builds from tomorrow the 29th of September, you will find a MultiInputDelimiters property of type char[]. The default is null which causes the control to behave in the normal way. By setting this property to be an array containing a comma and a space, you will get the behaviour displayed in the image you posted. Now multiple entries can be added to the AutoCompleteBox by using the delimiters. Each item will generate its own suggestion list. Changing the selected item in the drop-down-list will only affect the text at the current caret position. Try it out and let me know if there is any missing functionality. - Jason |
|
|
Thanks Jason. I thought it was an excellent feature also and is why I suggested it to be included. I will take the nightly build as soon as possible and will let you know if there is any functionality missing (it sounds like you got it though). |
|
|
Hi Jason, I have just integrated the latest nightly build with these changes. Our implementations were almost identical, except that you did not add a TypeConverter for the MultiInputDelimiters property so that it can be set from XAML using a string. Example: [TypeConverter(typeof(CharArrayTypeConverter))] Type converter implementation: public class CharArrayTypeConverter : TypeConverter What do you think about adding it in?
/Dennis |
|
|
Hello Dennis Thanks for the feedback, I have included the CharArrayTypeConverter in WPF Elements making it much more convenient to use the MultiInputDelimiters property. This will be available through the nightly builds from tomorrow the 18th of October. - Jason |
|
|
I'm just beginning to dig into the problem, but I'm getting a NullReferenceException from AutoCompleteBox on the 10/20 nightly build. At this point, I don't know of anything I've changed in my code that would trigger this
A first chance exception of type 'System.NullReferenceException' occurred in Mindscape.WpfElements.dll at Mindscape.WpfElements.AutoCompleteBox.#aX(Object sender, RoutedEventArgs e) |
|