Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Should I, or should I not use TreeViewItem as a base class?

$
0
0

Hello all,

I have a TreeView in WPF, I want to customize it's appearance. So to that end, I have created a class (without a base class) to represent an item in the TreeView, and customized it's appearance with  a TreeView.ItemTemplate.

This let's me make my TreeView items look exactly as I want, and it's great. The only problem is that how to I make these items support items within them? i.e. Let's say I want to show a directory hierarchy? I have tried creating an Items property, and filling that, but it makes no difference.

I can support a hierarchy very easily if I make my item have a base class of TreeViewItem, but then my ItemTemplate does not work, and I've tried other types of template too and they don't work.

I'd love to keep my items without a base class, as I can style them very easily, they just don't support child items. How can I do this? Is it simply not possible unless you have TreeViewItem as your base class? If that's the case, fine, I can work with that, I'd just like to know.

Thank you

Garry


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>