Search code examples
c#.netwpfsilverlightlistbox

Best way to change ListBox selection to be a toggle selection


I have a ListBox control that I want to change into having a toggle selection. i.e. Click once on an item selects it, click again it deselects it. Also, clicking another item in the list should do the default action of deselecting the previous item and selecting the new one.

What's the best way of achieving this?


Solution

  • What you want is a RadioButtonList. You can create one by creating an ItemDataTemplate and put a RadioButton inside it. Then you can modify the template of the RadioButton to looks like a button.