views:

44

answers:

1

Josh Smith wrote a clear, consise tour of working with the TreeView control in WPF. The secret to the success is the binding of IsExpanded and IsSelected properties of the viewmodel to the treeviewitems. The paper is here.

However after a day of attempting to map his approach to the Silverlight Toolkit TreeView I'm beginning to suspect that it's not possible.

I first stumbled on the binding issues with IsExpanded until I came across the suggestion of using a setter on an attached DependencyProperty. This looked promising, but still not working.

It seems there are some fundamental differences between the TreeView control with WPF and the Silverlight toolkit; differences that negate the possibility of driving the view from the view model, as Josh does in his wonderful example. Searching the viewmodel data and cascading the update IsExpanded=true up the hierarchy works great for Josh in WPF, but not so much for me in Silverlight.

Is in fact possible to 1) find a node in the hierarchy of viewmodel objects, and then set True all the IsExpanded properties from that node to the root, and have that reflected in the bound view?

(We're using MVVM-light if that's a help)

A: 

There seems to be no other way than to subclass the TreeView / TreeViewItem as discribed in this series of articles by Bea Stollnitz here, here, and here.

Ralph Shillington