Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
4155
XamComboEditor Multiple Selection Bug
posted

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

ComboEditorEnterKeySelection.zip
Parents
  • 34510
    Offline posted

    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.

Reply Children
No Data