【发布时间】:2012-12-26 10:55:10
【问题描述】:
我想在我的组合框中显示所有组名 (contact_grname),但只显示一项! 为什么会这样?!
<XmlDataProvider x:Key="TeleData" XPath="/response/contacts/contact">
</XmlDataProvider>
<CollectionViewSource x:Key="TeleView" Source="{StaticResource TeleData}" >
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="contact_name" Direction="Ascending" />
</CollectionViewSource.SortDescriptions>
<CollectionViewSource.GroupDescriptions>
<dat:PropertyGroupDescription PropertyName="contact_grname" />
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
<ComboBox ItemsSource="{Binding Source={StaticResource TeleView}, XPath=contact_grname}" />
我的 xml 文件:
<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
<contacts>
<contact>
<contact_grname>group1</contact_grname>
<contact_name>Bart</contact_name>
</contact>
<contact>
<contact_grname>group1</contact_grname>
<contact_name>Eric</contact_name>
</contact>
<contact>
<contact_grname>group2</contact_grname>
<contact_name>Mike</contact_name>
</contact>
</contacts>
</response>
只有 group1 出现(一次)。 当我在组合框中使用 StaticResource TeleData 而不是 TeleView 时,会显示所有组名(但有双精度值,因为没有以这种方式分组)
组合框中的预期输出:
- 组1
- 组2
现在我有了(使用 TeleView):
- 组1
如果我使用 Teledata:
- 组1
- 组1
- 组2
【问题讨论】:
-
尝试使用
/而不是_: -
这不是问题,这里写的时候打错了,我改了
-
contact_grname Iment :-)
-
你期望得到的输出是什么?