数据控件与文件访问技术详解
1. 数据控件操作
1.1 数据过滤
在数据展示中,有时我们只需要显示特定类别的产品。例如,仅显示“Travel”类别的产品,可通过以下代码实现:
PagedCollectionView view = new PagedCollectionView(e.Result);
// Show only travel items.
// The full list of products remains in the source collection, but the
// non-travel items are not visible through the PagedCollectionView.
view.Filter = delegate(object filterObject)
{
Product product = (Product)filterObject;
return (product.CategoryName == "Travel");
};
gridProducts.ItemsSource = view;
此代码创建了一个 PagedCollectionView 对象,并设置了过滤条件,使得只有“Travel”类别的产品会在 gridProducts 中显示。
1.2 数据分组
DataGrid 支持数据分组功能,能将行组织成逻辑类别。基本操作是选择用于分组的属性,例如
超级会员免费看
订阅专栏 解锁全文
3万+

被折叠的 条评论
为什么被折叠?



