SelectedItem binding

2 posts, 1 answers
  1. Miłosz Cechnicki
    Miłosz Cechnicki avatar
    34 posts
    Member since:
    Sep 2009

    Posted 05 Jul 2012 Link to this post


    I encountered an problem with setting SelectedItem from ViewModel.

    It occurs when I'm adding and/or removing an item from TreeView. After that action I force the SelectedItem to be set to actually added item, or the item following deleted one.
    Everything seems to be ok, but as You can see at attached screenshot, the item I'm trying to select is red one, but around other item (when adding the one, that was previously selected, when deleting - it seems it's a random element) is a light selection.
    And then it works as follows:
    1. When performing any action on "SelectedItem" - the action is performed on red item.
    2. When moving selection using up/down keys - next selected item is above/belowe the item with light selection.

    It's a bit confusing for users, who operate with keybord, e.g. removing some item...
  2. Answer
    Hristo avatar
    352 posts

    Posted 10 Jul 2012 Link to this post

    Hello Milosz,

    The "light selection" as you call it, is actually a visual indication for the focused element. Every keyboard operation is done in relation to the focused element. Thus using up/down arrows, editing, expanding and collapsing the item via the keyboard is done on the focused item.
    When selecting the item you could also focus it by calling Focus() method on the appropriate RadTreeViewItem.

    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft R3 2016 release webinar banner
Back to Top