简体   繁体   English

自动完成奇怪的行为

[英]Autocomplete strange behaviour

I have autocomplete with DataTemplate as: 我有DataTemplate自动完成为:

<my:AutoCompleteBox FontSize="18" TextChanged="z_TextChanged" SelectionChanged="z_SelectionChanged" Width="220" Name="z" FilterMode="Contains" >
                    <my:AutoCompleteBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding name}"></TextBlock>
                        </DataTemplate>
                    </my:AutoCompleteBox.ItemTemplate>
                </my:AutoCompleteBox>

And binding items like: 和绑定项,如:

myList = ListsClass.pList.Where(y => y.wID == wID).Distinct().ToList();
z.ItemsSource = myList;

myList type: SearchProd, with string name, int ID etc. myList类型:SearchProd,具有字符串名称,整数ID等。

My problem is that, when I put one letter on autocomplete I can see all items which name contains entered letter. 我的问题是,当我在自动完成功能上放一个字母时,我可以看到名称中包含输入字母的所有项目。 But when i click down/up arrow i can see on AutoComplete.Text: myNameSpace.Classes.SearchProd. 但是,当我单击上/下箭头时,可以在AutoComplete.Text上看到:myNameSpace.Classes.SearchProd。

What I'm doing wrong? 我做错了什么?

Thanks in advance! 提前致谢!

z.ValueMemberPath = "name"; z.ValueMemberPath =“名称”; was missing in code behind. 在后面的代码中丢失了。

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

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