I have a grid built using Grid 10 * 10. In the cells of this grid are Button elements created and placed there dynamically.
The question is how do I turn to these cells so that I can interact with the elements placed in them (for example, change their color, or the content property). I can not understand how this is done in WPF ..
Method to create a button.
private void CreateItemField(int i, int j, Brush color) { Button button = new Button(); button.Margin = new Thickness(0.5d); button.Background = color; button.Name = "btn" + i + j; MainGrid.Children.Add(button); Grid.SetColumn(button, i); Grid.SetRow(button, j); }