簡體   English   中英

樹形視圖的分層數據模板類

[英]hierarchical data template class for treeview

我想在我的項目中為樹視圖實現分層數據模板。 結構應如下所示:

- ManagedItems (RootItem)
     - Department 1
         -Client 1
             - Feature 1
             - Feature 2
         -Client 2
             - Feature 1
     - Department 2
             - Department 4
                     - Department 5
                            -Client 4
                                   - Feature 1
     - Department 3
         -Client 3
             - Feature 1
             - Feature 2
             - Feature 3


//Current class for datatype
public class Entries
{
    public string Department { get; set; }
    public string Client { get; set; }

    // ?? How to implement a drive array and a feature array which will be displayed correctly in the treeview?

    public ObservableCollection<Entries> Children { get; set; }
}

它在C#和WPF(.NET 4.0)中。 有什么想法嗎?

謝謝。

您模型的線框:

class ManagedItems {
   IList<Department> Departments // TreeView.ItemsSource
}
class Department {// HierDT
   IList<object> Children // HierDT.ItemsSource; (can either be Department or Client)
}
class Client {// HierDT
   IList<Feature> Features // HierDT.ItemsSource
}
class Feature { } // normal DataTemplate

TreeView.Resources定義DepartmentClient HierDTsFeature DataTemplate

注意Department.Childrenobjects 這是可以的,因為當WPF“看到”一個Client ,它將“膨脹”到適當的HierDT (以及當它“看到”一個Department ,也會膨脹到Department的定義的HierDT )。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM