This example looks like "TextSearch"
In the XAML file, you should add only one attribute to the combobox "TextContainSearch.Text":
<ComboBox ItemsSource="{Binding Model.formListIntDeviceNumbers}" SelectedItem="{Binding Path=Model.selectedDeviceNumber, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" DisplayMemberPath="DeviceNumber" IsEditable="True" c:TextContainSearch.Text="DeviceNumber">
And we must add use to the XAML file header:
xmlns:c="clr-namespace:Adaptive.Controls.Extension"
And the C # code in the * .cs file:
using System; using System.Windows; using System.Windows.Controls; namespace Adaptive.Controls.Extension { public sealed class TextContainSearch : DependencyObject { public static void SetText(DependencyObject element, string text) { var controlSearch = element as Control; if (controlSearch != null) controlSearch.KeyUp += (sender, e) => { if (sender is ComboBox){ var control = sender as ComboBox; control.IsDropDownOpen = true; var oldText = control.Text; foreach(var itemFromSource in control.ItemsSource){ if (itemFromSource != null) { Object simpleType = itemFromSource.GetType().GetProperty(text).GetValue(itemFromSource, null); String propertOfList = simpleType as string; if (!string.IsNullOrEmpty(propertOfList) && propertOfList.Contains(control.Text)) { control.SelectedItem = itemFromSource; control.Items.MoveCurrentTo(itemFromSource); break; } } } control.Text = oldText; TextBox txt = control.Template.FindName("PART_EditableTextBox", control) as TextBox; if (txt != null) { txt.Select(txt.Text.Length, 0); } } }; } } }
source share