views:

27

answers:

1

Hello I've got the following scenario: WPF Treeview displaying custom objects, each of them containing a list of children. So the problem is: Each of the custom objects is controlled by a combobox that can change the current object from Class A to Class B/C/D and vice versa. Classes A-D are all subclasses of a superclass. So far so good. Each class should be represented by a specific Datatemplate in the WPF treeview, so each time, the user changes the object class (using the inline-combo) the item should get a new template applied. So far I've tried: 1. DataTemplate Selector Class (gets only applied at start) 2. "nulling" DatatemplateSelector in treeview and reappling it after object change (too slow) 3. Datatemplate by class (x:Type) (works, but I need three different Templates per Object, one graphic, one minimum, one maximum display width with additional TextBlocks) 4. Datatrigger (I do not know how to databind it to the changed Class)

Might be some kind of systematic mistake. Your help is appreciated very much

Greets

Markus

A: 

The last solution is the best way to go (datatemplate on datatype)but in your datatemplate set the content to a contentcontrol with a datatrigger on the style property. overriding the control template based on your trigger precondition. alternatively you may want to consider a hierarchicaldatatemplate.

Steve Psaltis