private void createButton(int x, int y) { int mx = TILE_X_START + x; int my = TILE_Y_START + y; MapButton btn = buttons[x, y] = new MapButton(mx, my); btn.Width = BTN_SIZE; btn.Height = BTN_SIZE; btn.Style = (Style)Resources["tileStyle"]; btn.SetValue(Grid.ColumnProperty, x); btn.SetValue(Grid.RowProperty, y); btn.Click += btn_Click; btn.Content = getImage(x, y); grid.Children.Add(btn); // if (mx == 22 && my == 22) { btn.IsCurrentTile = true; } }