我的数据中有以下结构:
Category0
-SubCategory0
-SubCategory1
-SubCategoryN
Category1
-SubCategory1_0
-SubCategory1_1
-SubCategory1_N
一个类别将有一个名称、一个描述和一个唯一的整数 ID
例如
Category = Ford Description = "USA Car" Id = 12345678
-SubCategory: Name = Mondeo Description = "Some text" Id = 12324
-SubCategory: Name = Fiesta Description = "Some text" Id = 9999
-SubCategory: Name = Orion Description = "Some text" Id = 123456
-SubCategory: Name = Focus Description = "Some text"Id = 8799
该列表在设计时是已知的,我需要绑定到列表视图。我想将描述绑定为列表视图每一行的显示文本,并将值(具有名称和 ID 的对象或枚举)绑定为相应的值成员。
存储此信息的最佳方法是什么?我应该创建大量枚举吗?或者我应该使用分隔字符串(例如“Ford:Mondeo:Some Text:12324”)在设计器模式下直接绑定到列表视图,然后根据需要进行解析和提取。也许最好将数据存储为具有 id/description 值的自定义属性的强类型枚举,例如绑定到字符串是描述且 CarType 是具有属性的类的字典:Make(Ford):enum, Model(Modeo ):enum 和 Id(12324):int?