如何显示Silverlight组合框中项目的组头? [英] How to show group header for items in Silverlight combobox?

查看:135
本文介绍了如何显示Silverlight组合框中项目的组头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Silverlight中有一个组合框,其itemssource与 CollectionView 的 CollectionViewSource 绑定。

I have a combobox in Silverlight, whose itemssource is bound with a CollectionView of CollectionViewSource.

我还向 CollectionView 添加了 GroupDescription

现在我需要显示 ComboBox 中的项目,并且还需要显示组头。

Now I need to display the items in ComboBox grouped and also need to display the group header.

在WPF中有 ComboBox.GroupStyle ,我可以在其中定义组头。

In WPF, there is ComboBox.GroupStyle where I can define the group header. Whats the way to do it in Silverlight?

感谢

推荐答案

Silverlight组合框不支持分组。只需在绑定组合框之前对项进行排序,然后在组合框itemtemplate中显示组名和项名称就足够了?组合框项目将如下所示:

The Silverlight combobox does not support grouping. Would it be sufficient to just sort the items before binding the combobox and then displaying both the group name and the item name in the combobox itemtemplate? The combobox items would then look something like this:

类别:啤酒,名称:锚点Steam

类别:啤酒,名称:百威

类别:葡萄酒,名称:作品1

类别:葡萄酒,名称:Sassicaia

Category:Beer, Name: Anchor Steam
Category:Beer, Name: Budweiser
Category:Wine, Name: Opus 1
Category:Wine, Name: Sassicaia

这篇关于如何显示Silverlight组合框中项目的组头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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