I have stackpanel to which I am adding RadioButtons dynamically as children.
Radiobuttons have content which is integer.
I also have Y x Y grid (size determined from code dynamically), to which I'm adding dynamically Buttons and allow user to change Button's content into string which represents integer number.
Here is where I need help:
After checking arbitrary radiobutton from stackpanel, I'd like all buttons from grid that have same number to have their background color changed.
As I am new to WPF I am not sure how to achieve this and your help would be greatly appreciated.
EDIT: I made a little progress, what I do is basically bind Button.Content with RadioButton.IsChecked and RadioButton.Content for everybutton and every radiobutton, but I have problem that it only works for last radiobutton here is code (rbuts=parent control of radiobuttons, MyGrid=parent control of buttons):
for (int z = 0; z < boardSize * boardSize; z++)
{
Button b1 = MyGrid.Children[z] as Button;
for (int i = 0; i < boardSize; i++)
{
MultiBinding rbtnBinding = new MultiBinding();
rbtnBinding.Converter = new RadioButtonHighlightConverter();
rbtnBinding.Bindings.Add(new Binding("IsChecked") { Source = rbuts.Children[i] });
rbtnBinding.Bindings.Add(new Binding("Content") { Source = rbuts.Children[i] });
rbtnBinding.Bindings.Add(new Binding("Content") { Source = MyGrid.Children[z] });
rbtnBinding.NotifyOnSourceUpdated = true;
b1.SetBinding(Button.BackgroundProperty, rbtnBinding);
}
}
Its as if I cannot set many different multibindings for same button...