简体   繁体   English

绑定到 ItemSource

[英]Binding to the ItemSource

I'm trying to build dynamically a AutoCompleteBox.我正在尝试动态构建一个 AutoCompleteBox。 Then I want to use a list of Clients in my itemsource, and the user visualize the DescClient field.然后我想在我的项目源中使用客户列表,并且用户可视化 DescClient 字段。

List<Client> clients = ClientAction.getClientsFromUsers(Environment.UserName);
(field as AutoCompleteBox).ItemsSource = clients;

//CLIENT MEMBERS
    private int idClient;
            private string descClient;
            private int idGroup;
            private User user;

Already tried like:已经尝试过:

(field as AutoCompleteBox).ValueMemberPath = "DescClient"

But doesn't show anything.但是什么都不显示。 Am I doing something wrong afecting the ValueMemberPath or should I use another Proprety?我是否在影响 ValueMemberPath 时做错了什么,还是应该使用其他属性?

As stated here you can use ItemTemplate (there's also a reference on how to create DataTemplate from code, if you need it).如此处所述您可以使用 ItemTemplate (如果需要,还有关于如何从代码创建 DataTemplate 的参考)。

here a guide on AutoCompleteBox from Jeff Wilcox website. 是 Jeff Wilcox 网站上有关 AutoCompleteBox 的指南。

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

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