Hello,
I have found an issue with the XamComboEditor when Multiple Selection is enabled.
If the user presses the enter key to select an item that was already selected or types the items name twice an exception is thrown that cannot be handled because it originates from external code via "InfragisticsWPF4.Controls.Editors.XamComboEditor.v15.2". The exception messages is "Cannot select the same item multiple times." which makes sense but I cannot handle the exception.
I tried to bypass the exception by handling the PreviewKeyDown event for the combo editor and set the event's handled property to true if the currently selected item already has the IsSelected flag set to true. This works for the user navigating to the item via the arrow keys, however the exception is thrown before the PreviewKeyDown event fires when the user types in the same item name twice. I would like to bypass or handle this exception silently if possible so that either I can prevent the item from being selected twice or simply use a distinct list from the results.
See attached sample project for the error and my attempts to fix this.
Thanks,
Phillip
Hi Phillip,
Thanks for bringing this to our attention. I have notified our development team of this exception and there has been a dev issue logged for this (208667). I don't think the control should be causing the application to crash just because an item has been selected while already selected. In order for you to track the status of this I have created a private support case for you. The case number is CAS-165973-J8D8G7 and you can view it here: https://es.infragistics.com/my-account/support-activity
As far as a workaround goes for manually typing in the values, I'd recommend grabbing the TextBox where the user is typing and then altering the text to remove duplicate entries. If the user types in "item4,item5,item4" then the code should remove the last item4 as it is a duplicate. The PreviewKeyDown event should be a good spot for this. You can get the TextBox like this:
XamComboEditor combo = sender as XamComboEditor;var txtBox = (SpecializedTextBox)Utilities.GetDescendantFromName(combo, "TextBoxPresenter");
Then split the string by comma to get each sub item and then just compare them against each other, removing duplicates. Once finished, recombine the values with commas between them and give it back to the text box. I think e.Handled = true will be needed also.
This is very important to us, we will release the product to our customer.
Do you have any idea?
Hi Lin,
Are you positive that you are using the latest 15.2 version? The version number for that will be 15.2.20152.2100. The original issue reported by Phillip was resolved back in December 2015 and I have just confirmed this by running his provided sample against the latest version. The exception does not occur.
Are you doing something differently than what Phillip's sample is doing? If you have a sample that reproduces this or you have detailed steps I can follow, please let me know.