Quantcast
Viewing all articles
Browse latest Browse all 18858

AutoCompleteBox SelectedItem changes after dropdown closes

Hi everyone!

I have simple class Person:

public class Person
{
	public string Surname { get; set; }

	public string Name { get; set; }

	public string FathersName { get; set; }

	public Person(string surname, string name, string fathersName)
	{
		Surname = surname;
		Name = name;
		FathersName = fathersName;
	}
}

In xaml I have one AutoCompletebox with ValueMemberPath set to Surname and 2 simple text boxes with Name and FathersName of selected Person.

<controls:AutoCompleteBox ItemsSource="{Binding People}" 
						 ValueMemberPath="Surname" 
						 SelectedItem="{Binding SelectedPerson, Mode=TwoWay}" 
						 Text="{Binding EnteredSurname, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}"
						 FilterMode="Contains"
						 IsTextCompletionEnabled="False"
						 IsDropDownOpen="{Binding IsDropDownOpen, Mode=OneWayToSource}"
						 Grid.Column="1" Margin="5,0"><controls:AutoCompleteBox.ItemTemplate><DataTemplate><StackPanel Orientation="Horizontal"><TextBlock Text="{Binding Surname}"/><TextBlock Text="{Binding Name}" Margin="5,0,0,0"/><TextBlock Text="{Binding FathersName}" Margin="5,0,0,0"/></StackPanel></DataTemplate></controls:AutoCompleteBox.ItemTemplate></controls:AutoCompleteBox>

In 'People' collection I have 3 persons with equal Surname.

When I am choosing person in AutoCompleteBox I can see that selected item is proper. But after pressing Enter or mouse click to interesting person dropdown closes and SelectedPerson always switches to first Person despite what Person I have chosen.




Viewing all articles
Browse latest Browse all 18858

Trending Articles



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