Clear Selection

5 posts, 0 answers
  1. Lee
    Lee avatar
    7 posts
    Member since:
    Aug 2012

    Posted 04 Oct 2012 Link to this post

    I have placed a radlistbox in a dropdown button.  I have SelectionMode = Single.  I have an event handler for the selectionchanged to know which item they selected.  In that handler I set the dropdown button to close, get the item and clear the selection.  I do this so that the next time the user opens the menu there is not an item selected in the listbox.  I have tried 3 different things but the highlight of the item does not go away.  I have tried:

    SelectedItems.Clear();
    SelectedItem = null;
    SelectedIndex = -1;

    As previously stated, none of these clear the UI selection.  The SelectedItem property is set to null, but all previously clicked on items are still highlighted in the UI.

    Thanks in advance,
    Lee
  2. Lee
    Lee avatar
    7 posts
    Member since:
    Aug 2012

    Posted 04 Oct 2012 Link to this post

    What I am looking for is the equivalent to UnselectAll() that is on the windows version of this control.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Georgi
    Admin
    Georgi avatar
    349 posts

    Posted 09 Oct 2012 Link to this post

    Hi Lee,

    The reason behind this issue is that  by design the RadListBox does not expect to change the selection in the SelectionChanged event (this could trigger another SelectionChanged event). So what you can do is clear the selection when closing the DropdownButton.
    Attached you can find an example of that, it would be great if you can give it a try and let us know if this works for you.

    Kind regards,
    Georgi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Lee
    Lee avatar
    7 posts
    Member since:
    Aug 2012

    Posted 10 Oct 2012 Link to this post

    Your sample project shows the problem exactly.  Run your sample project and select item #2 in the list.  Now click the dropdown button.  You will see that item #2 is still highlighted and if you select it, then the radListBox_SelectionChanged is not fired.  Therefore, the selection is not being released.

    Please advise.
  6. Georgi
    Admin
    Georgi avatar
    349 posts

    Posted 15 Oct 2012 Link to this post

    Hi Lee,

    I am attaching video showing how it behaves using 2012.2.912 version of the controls, also I have slightly modified the project so the SelectedItem of the ListBox can be shown. Can you confirm that we are using the same version of the controls or if we differ in something else?

    Regards,
    Georgi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
UI for WPF is Visual Studio 2017 Ready