我已经用hashtable绑定了一个listview(网格),那么如何从那里获取物品?在使用哈希表之前,我只是做了ListViewA.SelectedItems;
,我正在获取源代码。当我用两个foreach
循环WPF Listview与Hashtable绑定
铱失败:
dlstTemplates
是我在WPF的ListView
foreach (var group in dlstTemplates.SelectedItems)
{
foreach (var Template in group)
{
}
}
错误2 foreach语句不能 的类型 '对象' 的变量 因为“对象操作'不包含 公共定义 'GetEnumerator'D:\ cs_InformeMedico \ app \ Template.xaml.cs 85 21 Demo.View
我发现这对调试器:
- dlstPlantillas.SelectedItems Count = 1 System.Collections.IList {System.Windows.Controls.SelectedItemCollection}
- [0] {System.Data.Linq.SqlClient.ObjectReaderCompiler.Group<string,Demo.View.Plantilla>} object {System.Data.Linq.SqlClient.ObjectReaderCompiler.Group<string,Demo.View.Plantilla>}
- Non-Public members
+ items Count = 97 System.Collections.Generic.IEnumerable<Demo.View.Plantilla> {System.Collections.Generic.List<Demo.View.Plantilla>}
key "101010112000" string
System.Linq.IGrouping<K,T>.Key "101010112000" string
- Results View Expanding the Results View will enumerate the IEnumerable
+ [0] {Demo.View.Plantilla} Demo.View.Plantilla
+ [1] {Demo.View.Plantilla} Demo.View.Plantilla
+ [2] {Demo.View.Plantilla} Demo.View.Plantilla
+ [3] {Demo.View.Plantilla} Demo.View.Plantilla
+ [4] {Demo.View.Plantilla} Demo.View.Plantilla
+ [5] {Demo.View.Plantilla} Demo.View.Plantilla
+ [6] {Demo.View.Plantilla} Demo.View.Plantilla
+ [7] {Demo.View.Plantilla} Demo.View.Plantilla
+ [8] {Demo.View.Plantilla} Demo.View.Plantilla
+ [9] {Demo.View.Plantilla} Demo.View.Plantilla
+ [10] {Demo.View.Plantilla} Demo.View.Plantilla
- Raw View
- [System.Windows.Controls.SelectedItemCollection] Count = 1 System.Windows.Controls.SelectedItemCollection
+ [0] {System.Data.Linq.SqlClient.ObjectReaderCompiler.Group<string,Demo.View.Plantilla>} object {System.Data.Linq.SqlClient.ObjectReaderCompiler.Group<string,Demo.View.Plantilla>}
+ Raw View
IsFixedSize false bool
IsReadOnly false bool
所以当组是
{System.Data.Linq.SqlClient.ObjectReaderCompiler.Group<string,Demo.View.Plantilla>} object type
对不起Plantilla =模板,我谮它更了解
我不能将模板作为groupCast中的属性,所以我必须在名为Templates的模板类中添加一个Default属性? – 2009-02-19 17:50:46