tags:

views:

3350

answers:

5

The built-in WPF TreeView control does not allow for multi selection, like a ListBox does. How can I customize the TreeView to allow for multi selection without rewriting it.

+1  A: 

I highly recommend Josh Smiths article on codeproject: Simplifying the WPF TreeView by Using the ViewModel Pattern

While his article doesn't cover multi select features it provides a great way of dealing with a TreeView in WPF.

There also seems to be another article that discusses an approach for a multi select TreeView here

Patrick Klug
+1  A: 

Another CodeProject project that more addresses your question more directly is this one: WPF MultiSelect TreeView Sample.

Govert
The code in that article is really badly written. I wouldn't recommend it to anyone. It's almost as if the author spends more time excusing his code than coding.
Anders Rune Jensen
+2  A: 

I've written a blog post on this topic,

Implementing Multi Select behavior on the WPF Tree View Control

mattdlong
Much better than the CodeProject article
Anders Rune Jensen
not bad at all mate!
TerrorAustralis
A: 

When I consider overriding the fundamental behavior of a control, like a treeview, I always like to consider the usability and effort associated with my decision.

In the specific case of a treeview I find that switching to a listview in combination with zero, one, or more controls makes for a more usable solution that often is easier to implement.

As an example, consider the common Open dialog, or Windows Explorer application.

Zamboni
A: 

You can also find a Multiple Selection View Control here: http://dotnetlearning.wordpress.com/2010/10/14/multi-selection-tree-view/

Marzio