Selected AutoSuggestBox Query Text Box

I am using an AutoSuggestBox control to display some results:

<AutoSuggestBox Width="192" PlaceholderText="Search" HorizontalAlignment="Right" ItemsSource="{Binding SearchResults}"> <i:Interaction.Behaviors> ... </i:Interaction.Behaviors> <AutoSuggestBox.ItemTemplate> <DataTemplate> <TextBlock> <Run Text="{Binding Name}" /> <Run Text="(" /><Run Text="{Binding Origin_Country[0]}" /><Run Text=")" /> </TextBlock> </DataTemplate> </AutoSuggestBox.ItemTemplate> 

SearchResults (ItemsSource binding) is defined as such:

  private ObservableCollection<ShowModel> _searchResults = default(ObservableCollection<ShowModel>); public ObservableCollection<ShowModel> SearchResults { get { return _searchResults; } set { Set(ref _searchResults, value); } } 

And ShowModel is the base model with related properties.

The problem I am facing is when I click on one of the results, it fills the text box using the model path, as shown below:

Before you select an entry:

After selecting an entry: enter image description here

I want to define some kind of template for a text field to bind to one of the model properties so that the path to the model does not appear. Is it possible?

+5
source share
1 answer

Set the TextMemberPath property for one of the model properties that you want to display.

 TextMemberPath="someproperty" 
+8
source

All Articles