繁体   English   中英

绑定到 ItemSource

[英]Binding to the ItemSource

我正在尝试动态构建一个 AutoCompleteBox。 然后我想在我的项目源中使用客户列表,并且用户可视化 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;

已经尝试过:

(field as AutoCompleteBox).ValueMemberPath = "DescClient"

但是什么都不显示。 我是否在影响 ValueMemberPath 时做错了什么,还是应该使用其他属性?

如此处所述您可以使用 ItemTemplate (如果需要,还有关于如何从代码创建 DataTemplate 的参考)。

是 Jeff Wilcox 网站上有关 AutoCompleteBox 的指南。

暂无
暂无

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

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