/// <summary> /// Change text. /// </summary> /// <param name="type">The type of text change that will occur.</param> /// <param name="text">The new value of the text.</param> /// <returns>A value indicating if the event was handled.</returns> private bool textChange( TextChangedType type, string text) { // Raise the PreviewTextChanged event PreviewTextChangedEventArgs e = new PreviewTextChangedEventArgs( PreviewTextChangedEvent, type, text); OnPreviewTextChanged(e); // Return a value indicating if the event was handled return(e.Handled); }
private void textBox_PreviewTextChanged(object sender, PreviewTextChangedEventArgs e) { selectedIndex = defaultIndex; var records = new List <object>(); var filterTextBox = e.Text; autoComplete.SelectedItem = null; autoComplete.SelectedValue = null; if (!string.IsNullOrEmpty(filterTextBox.Trim()) && !string.IsNullOrEmpty(FilterColumn)) { var filterItems = autoComplete.ItemsSource.Cast <object>(); filterItems = filterItems.Where(x => GetValueFromObject(x, FilterColumn) != null && GetValueFromObject(x, FilterColumn).ToString().ToLower().StartsWith(filterTextBox.ToLower())); records = filterItems.ToList(); } Popup.IsOpen = string.IsNullOrEmpty(filterTextBox) || records.Count > 0 ? true : false; BindItemsSourceToListBox(records, string.IsNullOrEmpty(filterTextBox)); lastSelectedText = filterTextBox; }
/// <summary> /// Raise a PreviewTextChanged event. /// </summary> /// <param name="e">The event arguments.</param> protected virtual void OnPreviewTextChanged( PreviewTextChangedEventArgs e) { RaiseEvent(e); }