How can I create board for simple game, looks like for chess,but user could dynamically change number of column and rows? In cells I could insert symbol of pawn, like small image or just ellipse or rectangle with fill. This board should have possibility add and remove pawn from cells and move pown from one cell to another.
My first idea was Grid. I do it in code behind, but it's hurt to implement events or everything in runtime create board :/
int size = 12;
Grid board = new Grid();
board.ShowGridLines = true;
for (int i = 0; i < size;i++ )
{
board.ColumnDefinitions.Add(new ColumnDefinition());
board.RowDefinitions.Add(new RowDefinition());
}
//komputer
Rectangle ai = new Rectangle();
ai.Height = 20;
ai.Width = 20;
ai.AllowDrop = true;
ai.Fill = Brushes.Orange;
Grid.SetRow(ai, 0);
Grid.SetColumn(ai,0);
//czlowiek
Rectangle hum = new Rectangle();
hum.Height = 20;
hum.Width = 20;
hum.AllowDrop = true;
hum.Fill = Brushes.Green;
Grid.SetRow(hum,size);
Grid.SetColumn(hum,size);
board.Children.Add(ai);
board.Children.Add(hum);
this.Content = board;
It's a way to do this dynamically col and row change in XAML ?
It's better way to implement that board create and implement events on move pawn from one cell to another ?