1
Vote

[WPF] AutoCompleteBox: oblige the user to select only items

description

Hi,
Is there a way for oblige the user to select only items shown in list?
I would avoid that user can to insert custom words in database.

Thanks.

comments

robertosalemi wrote Apr 20, 2015 at 8:32 AM

Hi,
I resolved with this way:
private void PropertyAutoCompleteBox_MouseLeave(object sender, MouseEventArgs e)
{
   SampleProperty lastRow = (SampleProperty)dgProperties.SelectedItem;

    if ((sender as AutoCompleteBox).SelectedItem != null && (sender as AutoCompleteBox).SelectedItem.GetType() == typeof(BaseDataProperty))
    {
        BaseDataProperty selectedItem = (BaseDataProperty)(sender as AutoCompleteBox).SelectedItem;

        //[MY_CODE]
    }
    else
        //SHOW MESSAGE
}
I hope this is helpful to someone.