This is a migrated thread and some comments may be shown as answers.

Keyboard Events for RadTreeView Checkbox

4 Answers 191 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Pelli
Top achievements
Rank 1
Pelli asked on 08 Jun 2015, 08:42 AM

Hi,

As CheckedItems Event  of RadTreeView is not giving results properly, we implemented RadTreeView Checkbox using MVVM using http://docs.telerik.com/devtools/wpf/controls/radtreeview/how-to/howto-tri-state-mvvm. Now, we are able to get the checked items properly.

Now, how should we support keyboard events like by pressing CTRl+Space , Node should get selected. Is there any way to handle this. If we do not use MVVM TriState check box, we can acheive by setting the property "IsOptionElementsEnabled" to true.

Please let me know your inputs.

Thanks,

Subhashini

 

 

4 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 09 Jun 2015, 02:39 PM
Hi Pelli,

To achieve this functionality in the MVVM scenario you will need to implement it with custom code. For example you can subscribe for the RadTreeView's KeyDown event and inside of it get the currently selected note and check it. The following code snippet demonstrates this approach for the MVVM implementation from the related help article.
this.tree.AddHandler(RadTreeView.KeyDownEvent, new KeyEventHandler(tree_KeyDown), true);
 .....
void tree_KeyDown(object sender, KeyEventArgs e)
{
    if (Keyboard.Modifiers == ModifierKeys.Control && e.Key == Key.Space)
    {
        var selectedCategory = (CategoryViewModel)this.tree.SelectedItem;
        selectedCategory.IsChecked = !selectedCategory.IsChecked;
    }
}

Please try this and let me know if it works for you.

Regards,
Martin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Pelli
Top achievements
Rank 1
answered on 10 Jun 2015, 11:10 AM

Hi Martin,

Thank you for your inputs. I am able to check/uncheck checkbox in radtrreview through keyboard inputs..

Thanks,

Subhashini

 

 

0
Pelli
Top achievements
Rank 1
answered on 10 Jun 2015, 12:36 PM

Hi Martin,

I am able to acheive this only for single selected item. If I select multiple items through Shift key and press space button, only the last selected item is checked. Can you please provide inputs on this.

Thanks,

Subhashini

0
Martin Ivanov
Telerik team
answered on 11 Jun 2015, 08:50 AM
Hi Subhashini,

In order to achieve the desired functionality for multiple selection you can use the SelectedItems collection of the treeview.
void tree_KeyDown(object sender, KeyEventArgs e)
{
    if (Keyboard.Modifiers == ModifierKeys.Control && e.Key == Key.Space)
    {
        foreach(CategoryViewModel category in this.tree.SelectedItems)
        {
            category.IsChecked = !selectedCategory.IsChecked;  
        }       
    }
}

Regards,
Martin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
TreeView
Asked by
Pelli
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Pelli
Top achievements
Rank 1
Share this question
or