Keyboard Events for RadTreeView Checkbox

5 posts, 0 answers
  1. Pelli
    Pelli avatar
    11 posts
    Member since:
    May 2014

    Posted 08 Jun 2015 Link to this post

    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

     

     

  2. Martin Ivanov
    Admin
    Martin Ivanov avatar
    1385 posts

    Posted 09 Jun 2015 Link to this post

    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
  3. Pelli
    Pelli avatar
    11 posts
    Member since:
    May 2014

    Posted 10 Jun 2015 in reply to Martin Ivanov Link to this post

    Hi Martin,

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

    Thanks,

    Subhashini

     

     

  4. Pelli
    Pelli avatar
    11 posts
    Member since:
    May 2014

    Posted 10 Jun 2015 in reply to Pelli Link to this post

    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

  5. Martin Ivanov
    Admin
    Martin Ivanov avatar
    1385 posts

    Posted 11 Jun 2015 Link to this post

    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
Back to Top