That's abstract like in: You will have to write some code (gasp!) in order to getting started. Extending TreeViewBaseĪll the features of V-Tree are being provided by the abstract TreeViewBase class. As I'll refer to WPF's built-in TreeView control a lot, I'll call it V-Tree throughout this article (which is completely random, btw). However, I won't write that all over the place because that just sounds horribly narcistic, and it doesn't really make sense here at CP anyway. Regarding terms: Actually, this is the " WPF TreeView Control," as I published the initial version on my blog. If you're already tired of reading, you might just download the sample, play around, and come back later if you need more information. Pretty much everything I am going to write here is illustrated in the sample application that comes with the download. The tree layout (expanded/selected nodes) can be saved and reapplied.Various extension points - a lot of code is virtual and can be overridden in order to control the behavior of the tree - down to the creation of single TreeViewItem instances.You can get a tree node (UI) by a bound item (data) and vice versa, or recursively iterate through all your tree nodes. This resolves reloading and focus issues with the control. Internally, there is a clear distinction between UI (tree nodes) and bound items.And as opposite to the standard TreeView, the SelectedItem property is not read-only. The tree provides simple and type-safe access to the underlying data (no properties of type object here).You can tweak the tree for maximum performance, minimum memory footprint, or even a fully virtualized solution that gets data on demand and keeps it cached until you decide to remove it explicitly.Here's the most important features at a glance: Lazy Loading, Caching, and Memory Consumption.Which is why I have to write that darn article now. The result was simple yet effective, so I decided to extend it a little in order to get a generic control which I could reuse and share with the community. This solution took care of my issues (at least the tree-related ones while I could still rely on the basic functionality of TreeView without having to reinvent the wheel. The result was a composite control I built around TreeView. Furthermore, I faced a few other issues when the tree's data source was refreshed or replaced, which caused nasty side effects with TwoWay data binding.īottom line was that the purely data-driven UI didn't quite work in my case - I needed an alternative. While data binding had served me very well so far, I just needed more control from code when it came to that tree. However - I soon reached limits that proved hard to get around. Data was hierarchically organized, and I had to provide a lot of different views on isolated and merged data sources based on a variety of external factors.įirst of all: I 'love' data binding in WPF - it just makes a lot of things so easy! So in order to display nested data on a TreeView control, I started with a hierarchical data template. I was recently working on a WPF project, and it was all about data editing and synchronization. Download source and demo project (VS 2008) - 88.62 KB.Download binaries (.NET 3.0 for VS2005 users) - 96.15 KB.
0 Comments
Leave a Reply. |