This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I was preparing to implemented a keyup handler when it occurred to me I might not need to. I've got a heavily styled MultiColumnTreeview and I'd like keyup/down to only navigate my root nodes. Is that something straightforward to adjust? Using WPF Elements 4, build from 10/25/2011, if it matters. I don't mind upgrading to 5 if it would help me, I just haven't gotten around to it. Thanks! |
|
|
Hello This feature does not currently exist and we do not plan to implement this into the control. However, for convenience I have attached a sample that demonstrates one possible way that you could implement it yourself. Here is how it works: 1) In xaml, hook up an event handler for the TreeViewItem.Selected event like this:
In the event handler, store the TreeViewItem in a field like this:
2) Listen to the PreviewKeyDown event of the MulticolumnTreeView. The event handler would look like this:
Here we find the index of the selected item and change this depending on which key was pressed. Near the end of the method we use the item container generator to get the TreeViewItem for the new index and select it. It is also important to use the Focus method here. If the currently selected item is not a root (which can happen by using the mouse), then I have included logic to find the root of the selected item which can be used to find the appropriate index. At the very end of this method, use e.Handled = true to disable the default navigation. You may want to only do this if the Up or Down key was pressed. The way I have done it will disable all default key operations. The GetRoot method mentioned in the code above is a method that iterates up the visual tree to find the root TreeViewItem of the currently selected item. The code for this method is in the attached sample. If you need to run the sample, make sure to include a reference to your copy of the Mindscape.WpfElements.dll. This code will work for both 4.0 and 5.0. That said, I would recommend upgrading to the latest version as soon as you can anyway. There were not many breaking changes, but let me know if you run into trouble. If this code absolutly is not going to work in your application, then let us know and we will see if we can build it into the control. Or if you come up with a more simple implementation of what I have done here, then I would love to hear about it. Let us know how it goes. Jason Fauchelle |
|
|
Thanks so much for the clarity on the controls features and the sample. Since I already maintain a selected object, my implementation ended up being a lot simpler.
WorkingChangeSelected is something I've been using for a while since I had issues in the past with element.IsSelected randomly failing. Probably overkill.
I don't want to upgrade to 5.0 because then I'll be wanting to try out your datagrid instead of the WPF Toolkit one I'm already using, and I don't have time for that :). Also, I didn't realize I had a license for it until a few days ago. |
|
|
Great to see you got it working well! Jason Fauchelle |
|