0
votes

i have the following scenario:

I have a ViewModel with hierachical elements to display in a TreeView. So far so good. What i want to do now is hide/remove elements from the TreeView according to some property set on a ViewModel-Element, like IsConfigurable or such. If i disable die DataTemplate, the element is removed, but also all child-elements, which is not what i want.

Is that even possible?

Greets,

Jürgen

1
You want to remove parent node but not children? But what the children will be bound to?Zabavsky
Do you want to hide the Header of the parent node and keep its children under that same blank node?WPF-it
I kinda want to 'hide' a node and hook its childs to the next parent in hierachie... but without meddling with the collection itself... Like i said, i don't know if that's even possible.opiswahn

1 Answers

0
votes

That sounds somewhat strange, but nevertheless...

You should consider that your application shall remain test and debuggable.
Your model contains the orginal data (collection) as it is - no meddling here. In your ViewModel, the object that you are binding to, you can calculate the transformation as you want to display your hierarchy. This approach has the benefit, that you can "easily" test/debug your transformation. Now bind your TreeView to the calculated hierarchy without obscure experiments. If properties in your ViewModel (you mentioned IsConfigurable or whatever) change, you know when to re-calc your bound hierarchy.