So I want to set the currently selected button to green background in a listbox while all buttons that are not selected should stay black. How can I do this. View examplecode below.. cant get it working though.
foreach(Button btn in ListBox.Items)
btn.Background = new SolidColorBrush(Colors.Black);
Button clickedButton = sender as Button;
clickedButton.Background = new SolidColorBrush(Colors.Green);
If you want it that way (without Binding and converters) here you go:
(I’m also assuming that only a button is in the listbox item)