集合的子集绑定 [英] Bind subset of collection

查看:149
本文介绍了集合的子集绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的ObservableCollection<&人GT; 对象。在对象有名称键入属性,其中键入学生教师。有没有什么办法来绑定组合框的ObservableCollection℃的子集;人> 对象,其中键入属性仅教师

I have an ObservableCollection<Person> object. The Person objects have Name and Type properties, where Type is either student or teacher. Is there any way to bind a ComboBox to a subset of the ObservableCollection<Person> object, where the Type property is only teacher?

推荐答案

您可以编程如下做到这一点:

You can do this programatically as follows:

MyComboBox.ItemsSource = a.Where((obj, r) => { return (obj.Type == "student"); }).ToList();

这篇关于集合的子集绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆