简体   繁体   English

AutoSuggestBox查询选定的文本框

[英]AutoSuggestBox query selected textbox

I am using an AutoSuggestBox control to display some results, as such: 我正在使用AutoSuggestBox控件来显示一些结果,如下所示:

                <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: SearchResults (ItemsSource绑定)定义如下:

    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. ShowModel是一个具有可绑定属性的基本模型。

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? 这甚至可能吗?

TextMemberPath属性设置为要显示的模型属性之一。

TextMemberPath="someproperty"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM