How to get TreeViewItem from HierarchicalDataTemplate item?

TreeViewItem item = (TreeViewItem)(mainTreeList .ItemContainerGenerator .ContainerFromIndex(mainTreeList.Items.CurrentPosition)); DOES NOT WORK (for me) as mainTreeList.Items.CurrentPosition in a treeview using a HierarchicalDataTemplate will always be -1. NEITHER DOES below as as mainTreeList.Items.CurrentItem in a treeview using a HierarchicalDataTemplate will always be null. TreeViewItem item = (TreeViewItem)mainTreeList .ItemContainerGenerator .ContainerFromItem(mainTreeList.Items.CurrentItem); INSTEAD I had to set a the last selected TreeViewItem … Read more

WPF Treeview Databinding Hierarchal Data with mixed types

Since you want the elements in the TreeView to have a list of children that consists of both Categories Products, you will want your Category ViewModel to have a collection that consists of both Categories and Products. For example, you could use a CompositeCollection to combine your existing collections: public class Category { public string … Read more

WPF TreeView HierarchicalDataTemplate – binding to object with multiple child collections

A HierarchicalDataTemplate is a way of saying ‘this is how you render this type of object and here is a property that can be probed to find the child nodes under this object’ Therefore you need a single property that returns the ‘children’ of this node. e.g. (If you can’t make both Group and Entry … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)