如何动态设置TreeView

时间:2013-08-30 16:08:12

标签: wpf treeview hierarchicaldatatemplate

使用WPF我希望有一个TreeView可以显示来自Compact Database的数据。这意味着我想根据用户希望如何排序来更改视图。

假设数据库具有以下表格和架构,我该如何设置我的视图?正如我所说,它们应该是可变的,但如果可能的话,我会考虑多个HierarchialDataTemplates。下面列出了一些潜在的想法。

感谢您提供的任何帮助!

Employee
ID - Int primary Unique AutoIncrement
Name – string
Department -  int (foreign relation to Department. ID)
Supervisor - int (ID of Employee in this table)

Division
ID - Int primary Unique AutoIncrement
Name – Unique string
DivisionLeader - int (foreign relation to Employee. ID)

Department
ID - Int primary Unique AutoIncrement
Name – Unique string
DepartmentLeader - int (foreign relation to Employee. ID)
Division – int (foreign relation to Division. ID)

CustomerSupportDepartments
ID - Int primary Unique AutoIncrement
Name – string
Department - int (foreign relation to Department. ID)
Continent - int (foreign relation to Continent. ID)
Country - int (foreign relation to Country. ID)
State - int (foreign relation to State. ID)
City - int (foreign relation to City. ID)

Customer
ID - Int primary Unique AutoIncrement
Name – string
SalesRep - (foreign relation to Employee. ID)
Revenue . int
Continent - int (foreign relation to Continent. ID)
Country - int (foreign relation to Country. ID)
State - int (foreign relation to State. ID)
City - int (foreign relation to City. ID)

Continent
ID - Int primary Unique AutoIncrement
Name – Unique string

Country
ID - Int primary Unique AutoIncrement
Name – Unique string

State
ID - Int primary Unique AutoIncrement
Name – Unique string

City
ID - Int primary Unique AutoIncrement
Name – Unique string

潜在观点

View 1
Employees
    Employee Name 1
        Supervisor
            Name
        Department
            Name
        Customers
            Name 1
            Name 2
            Name 3
     Employee Name 2
        Supervisor
            Name
        Department
            Name
        Customers
            Name 1
            Name 2
            Name 3
    View 2
    Departments
        Department Name 1
           Division
                Name
            Supervisor
                 Name
            Employees
                 Employee Name 1
                Employee Name 2
       Department Name 2
            Division
                Name
             Supervisor
                Name
             Employees
                 Employee Name 1
                 Employee Name 2


View 3
Divisions
    Division Name 1
        Departments
            Department Name 1
            Department Name 2
    Division Name 2
        Departments
            Department Name 1
            Department Name 2

View 4
Continents
    Continent Name 1
        Country Name 1
            City Name 1
                Customers
                    Customer Name 1
                    Sales Representative
                        Employee Name
                    Revenue
                        Sum
                    Customer Name 2
                    Sales Representative
                        Employee Name
                    Revenue
                        Sum
        Country Name 2
            City Name 1
                Customers
                    Customer Name 1
                    Sales Representative
                        Employee Name 1
                    Revenue
                        Sum
            City Name 2
                Customers
                    Customer Name 1
                    Sales Representative
                        Employee Name 1
                    Revenue
                        Sum
                    Customer Name 2
                    Sales Representative
                        Employee Name
                    Revenue
                        Sum

View 5
Customers
    Customer Name 1
        Sales Representative
            Employee Name
        Sales Representative’s Supervisor
            Employee Name
        Location
            Continent
            Country
            State
            City
        Revenue
            Sum
    Customer Name 2
        Sales Representative
            Employee Name
        Sales Representative’s Supervisor
            Employee Name
        Location
            Continent
            Country
            State
            City
        Revenue
            Sum

1 个答案:

答案 0 :(得分:0)

我使用通用对象结束了。

相关问题