I'm trying to use AutoCompleteBox
in my program, but something unwanted happens when I run the application. The problem is that dropdown list of filtered elements shows only name of binded class. When I click on any element, correct value in AutoCompleteBox
is set.
Example:
View
<controls:AutoCompleteBox Grid.Column="0"
Grid.Row="5"
Margin="1"
ItemsSource="{Binding RadiatoryComboBoxItem}"
SelectedItem="{Binding SelectedRadiator, Mode=TwoWay}"
ValueMemberBinding="{Binding Value}"
ValueMemberPath="Value"
Text="{Binding SelectedRadiator}" />
ViewModel
public IQueryable<ComboBoxKeyAndValue> RadiatoryComboBoxItem
{
get
{
return
(
from value in tetraEntities.Radiatory
select new ComboBoxKeyAndValue
{
Key = value.idRadiator,
Value = value.nameRadiator
}
).ToList().AsQueryable();
}
}
Please help.
The problem is solved. All what I've done was overriding method ToString() in my class which was binded as a ItemSource.