I've three toggle buttons: b1, b2, b3 and I put them in an array like this:
ToggleButton[] btnArray = new ToggleButton[] {b1, b2, b3};
If b1 is clicked, b1.FontWeight = FontWeights.Bold
, and b2 & b3 equal to Normal. If b2 is clicked, b2.FontWeight = FontWeights.Bold
, and b1 & b3 equal to Normal. If b3 is clicked, b3.FontWeight = FontWeights.Bold
, and b1 & b2 equal to Normal.
b1 b2 b3
O X X
X O X
X X O
I know the easiest way to update each toggle button is listing down one by one, but it will make my code looks so duplicated. I've other toggle buttons' properties need to be updated at the same time as well. So, how can I use for loop to make it less duplicated? Or is there any other better way to do this?