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
4341
Set XamComboEditors text to highlighted item from the drop down list
posted

Hello Support,

When using a non-editable XamComboEditor, if the drop down is open and the user starts typing, the item matching the user input gets highlighted within the drop down list. However the highlighted item from the drop down list does not get filled in the combo’s text area. This works well if the XamComboEditor is editable. However, we need a non-editable combo in order to avoid invalid user inputs. Can you please tell us if there is any other way to achieve this functionality. We have attached herewith a screenshot of our requirement for your reference. Thank You.

Parents
No Data
Reply
  • 405
    posted

    Hello.

    Thank you for your post!

    I will provide you with guidance on how to achieve the behavior that you described. Let me know if you need any additional assistance and I will be more than happy to help you.

    As of now, there is no property that you can use to add the highlighted item in the xamComboBox textbox area while typing.

    In order to simulate the behavior, you can handle the KeyDown event of xamComboBox. When handled, you add the following logic in it:

    1)      Track the key that has been pressed. On the next key pressed, append the letter to a string or StringBuilder object.

    2)      Cast the ItemsSource property of xamComboEditor to a generic collection by using the Cast method, i.e. ItemsSource.Cast<ModelObject>().ToList().

    3)      Retrieve the elements in the collection that start with the current key sequence. These elements will be the ones that match the sequence that the user has typed so far. You can retrieve the elements by using Where() and StartsWith() LINQ clauses to the collection from step 2.

    4)      If the collection that you retrieved in step 3 is not empty, then the first element in it will be the element that is highlighted in the dropdown. Finally, you need to get the information from it using the First() LINQ clause and set it to the Text property of xamComboEditor.

    To reset the string that holds the key sequence, you can use the DropDownClosed event of xamComboEditor. The other situation when you reset the sequence is when the time interval between two presses is too big.

    Please let me know if this helps you or you need further assistance on this matter.

    Looking forward for your reply.

     

    Sincerely,

    Lazar Nikolov

    Infragistics

    www.infragistics.com/support

Children