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
25
How to not allow user to enter value not in itemsource
posted

Hi experts,

When using xamMultiColumnComboEditor and filter on all columns. If I type for example:"aaa", it will filter out some rows contains "aaa", but if I click anywhere else outside of xamMultiColumnComboEditor before clicking the rows filtered out, "aaa" will stay on the xamMultiColumnComboEditor. Could you please advise how to empty the "aaa" when clicking anywhere outside of xamMultiColumnComboEditor before selecting the row?

Thanks,

suqing

Parents
  • 16495
    Verified Answer
    Offline posted

    Hello Qing li,

    I could suggest you  to find the SpecialixedTextBox element that is used in the XamMultiComboEditor to display selected or entered text. Then you could handle DropDownClosed event and easily set the Text to empty string if the SelectedItem is equal to null. The following code snippet illustrate the suggested approach:


                      DisplayMemberPath="Name"
                      FilterMode="FilterOnAllColumns"
                      DropDownClosed="myCombo_DropDownClosed" />


    private void myCombo_DropDownClosed(object sender, EventArgs e)
    {
        if ((sender as XamMultiColumnComboEditor).SelectedItem == null)
        {
            SpecializedTextBox sptxt = Utilities.GetDescendantFromName((sender as XamMultiColumnComboEditor) as DependencyObject,
                "TextBoxPresenter") as SpecializedTextBox;
            if (sptxt != null)
                sptxt.Text = "";
        }
    }

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

    Sincerely,
    Zhivko
    Entry Level Software Developer

Reply Children
No Data