I am using an AutoSuggestBox control to display some results, as such:
<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 a basic model with bindable properties.
The problem I'm having is when I'm clicking on one of the results, it is filling the textbox with the path of the model, as seen below:
Before selecting an entry:
After selecting an entry:
What I want is to define some sort of template for the textbox to bind to one of the model's properties so the model path is not displayed. Is this even possible?
Set TextMemberPath
property to one of model's properties that you want to display.
TextMemberPath="someproperty"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With