I also tried writing some code that handles GotFocus and GotKeyboardFocus of all TreeViewItems and then use FindName to get at the CheckBox and give it focus. I tried setting Focusable on the ItemContainerStyle to false, but then the keyboard navigation does not work properly. I find that the TreeViewItems want to take focus first, requiring me to press an arrow key twice to bring focus to the contained CheckBox. I want it so that the user can easily navigate through the tree and press Spacebar to check/uncheck an item's CheckBox. Suppose I have a TreeView where items should all contain CheckBoxs.
I just can't find a way to do this, even after trying several hacks. I have to have some code behind to handle this change).I have a WPF programming question for you all. If anyone can find a solution that does not prevent this I'd still be happy but I'd have to find some way to handle that drag separately (e.g. dragging John from Room 1.02 to Room 1.03) is not extremely strict. Note: the requirement of not being able to drag items to a different parent (e.g. So I thought I should put the properties in a Style instead, and apply a ItemContainerStyle to the TreeViewItem, but that doesn't work either (no dragging possible at all).Īm I being too difficult or am I just missing something? I can't find a way to enable dragging of the children separately, as I don't have any TreeViewItem for them (those are created on the fly by the TreeView in the binding I'm guessing). When I try to drag either of them, it actually drags the entire parent Team. So I cannot drag Offices or Persons at all. While this works for the Teams (I can drag to re-order all teams), I can not drag any children. The furthest I've been able to achieve is simply enabling the drop target and drag source on the original TreeViewItem that hosts the Teams. However, if this condition is too difficult, it may be acceptable to allow this after all.įinally, I don't want the ability to drag Buildings at all. The same goes for Persons - I should not be able to drag a Person from Room 1.01 to Room 1.02. I also do like the ability to drag one Office to another Team, it should only be possible to drag Offices within their original parent Team. I do not want the ability to drag an Office into another Office, or a Person into a Team, or something "impossible" like that. And I want to change the order of the Persons within a single Office. At the same time, I also want to be able to change the order of the Offices within a single Team. Now I want to be able to change the order of the Teams by dragging them. So the hierarchy is Team -> Office -> Person. A Team further consists of a list of Offices (or rooms), and an Office finally has multiple Persons.
The TreeView is showing a list of Teams, and a list of Buildings (not important).
Furthermore, I want to enable dragging for all of the child levels, but again only within their own parent. The dragging should only ever cause a re-ordering of the items, it should not be able to drop inside of a child or inside of a different parent (as in the Treeview example). The TreeView has multiple levels and multiple root nodes, and I only want to implement the dragging for one of the root nodes (the others should not support dragging at all). I am trying to implement a simple "drag to re-order" functionality for my TreeView.