wpf - Grouping a tree view with a different source -


I'm new to WPF world, and I'm trying to apply an application according to the MVVM design pattern. I am having some problems when it comes to using revivions.

My model is a list of log insents (from different apps) with the following properties: message, severity, application I have a collection in which there are 6 items related to two different applications. I want to See the view of my tree as follows:

App A
Error
First Error Message (AAA)
Second Error Message (BBB) ​​
Warning
First Warning Message (CCC)
APB Alert
First Warning Country (DD)
Information
First Information Message (EE)
Second Information Message (FFF)

My current understanding is that having an item with the list of children , So I want to create such a scene that I will need to create a list that contains string (application name) and a list of children (different abnormality) in which the list of children (display message) .

It does not make sense to me because I am making the dependence between my scene and my model, we say that in the future, any other hierarchical layer needs to be added, to support it You will need to change your data structure.

Do you have a method to have only one list with different groups?

Thank you.

You can easily group your data with CollectionView Even in nested ways:

  ObservableCollection & lt; LogEntry & gt; New logentry ("App1", "Warning", "MGS1"), New Logentry ("AP1", "Error", "MSS 2"), New Logentry ("app1 new logentry" ("app 2" New logentry ("app2", "mg5 5" }); See ListCollectionView = (ListCollectionView) CollectionViewSource.GetDefaultView (View) View Group Details (New Property Group Details ("Applications")) View Group Details Add New Property Group Details ("Severity" ); Data = View;   

(You can also create a collection view view in XAML, this is just an example)

You can now display it using datatamlets Can be:

   ItemsSource = "{Binding Data.Groups}" & gt; & gt; TreeView.Resources & gt; & lt; hierarchical dataTypeplate dataType = "{x : Type archive view group} "Item Source =" {Binding Item} "& gt; TextBlock Text =" {Binding Name} "/>   & Lt; / DataTemplate & gt; & Lt; /TreeView.Resources> & Lt; / TreeView & gt;   

It looks like:


Comments