phito
phito

Reputation: 28

Binding a treeview to a list and group the items in function of a property

Here's a simplified version of what I have :

class Account
{
    public string Name { get; set; }
    public string GameServer { get; set; }
}

And i'd like to get a TreeView from a list of theses accounts, and group them by server, like this :

Tree

Is there a way to do it?

Thanks

Upvotes: 0

Views: 689

Answers (1)

dev hedgehog
dev hedgehog

Reputation: 8791

You are asking for code without trying it yourself. I dont think such behavior is gladly welcome here. Anyways I will gladly spam you with links that you could have found yourself on the internet.

http://www.wpf-tutorial.com/treeview-control/simple-treeview/

http://msdn.microsoft.com/en-us/library/system.windows.controls.treeview.aspx

http://www.c-sharpcorner.com/UploadFile/mahesh/treeview-in-wpf/

Check them out.

EDIT:

For HierarchicalDataTemplate see this: http://blogs.msdn.com/b/mikehillberg/archive/2009/10/30/treeview-and-hierarchicaldatatemplate-step-by-step.aspx

EDIT 2:

If you wish to use grouping function. Read this: http://wpftutorial.net/DataViews.html

Upvotes: 1

Related Questions