protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            SearchAutocmpleteItem saItem = element as SearchAutocmpleteItem;

            saItem.DataContext = item;
            saItem.BindingPath = SearchPropertyBindingPath;
            focusableItems.Add(saItem);
            saItem.HighlightString = SearchString;
            base.PrepareContainerForItemOverride(element, item);
        }
        protected override void ClearContainerForItemOverride(DependencyObject element, object item)
        {
            SearchAutocmpleteItem itemContainer = element as SearchAutocmpleteItem;

            if (itemContainer != null)
            {
                itemContainer.IsSelected = false;
                if (focusableItems.Contains(itemContainer))
                {
                    focusableItems.Remove(itemContainer);
                }
            }
            base.ClearContainerForItemOverride(element, item);
        }
 private void SelectItem(SearchAutocmpleteItem item)
 {
     if (item == null)
     {
         refreshHighlightString      = false;
         SelectedItem                = null;
         _editableTextBox.Text       = SearchString;
         _editableTextBox.CaretIndex = _editableTextBox.Text.Length;
         refreshHighlightString      = true;
     }
     else
     {
         SelectedItem                = item;
         refreshHighlightString      = false;
         _editableTextBox.Text       = SelectedItem.DisplayString;
         refreshHighlightString      = true;
         _editableTextBox.CaretIndex = _editableTextBox.Text.Length;
     }
 }