Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

AutoCompleteTextBox in WPF C#

$
0
0

I've seen a number of suggestions for AutoComplete in WPF on a TextBox. However, they are all years old by now and many are expired without working websites.

Basically, I'm going to want to bind the TextBox to an ObservableCollection with a Model of a  Person. Their Name will be displayed wen the user types as a suggestion, and will be displayed when the user selects said Person. 

However I also want to be able to access the selected Persons ID aswell. Is there a TextBox that is still current and can achieve what I would like it to do?

I've attempted to use WPF TextBox AutoComplete like so;

<TextBox Text="{Binding SelectedItem.ContactMadeBy, ElementName=contactsDataGrid, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" behaviors:AutoCompleteBehavior.AutoCompleteItemsSource="{Binding EmployeeCollection}"/>

but nothing happens when I type. I've looped through EmployeeCollection and it is definitely populated, so the issue lies with the TextBox. An additional problem to this is that it needs to be bound to an IEnumberable<string> where I can't have the Persons ID as well.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>