private void Button_Run(object sender, MouseEventArgs e) { Random randomValue = new Random(); NoButton.SetValue(Grid.RowProperty, randomValue.Next(0, 6)); NoButton.SetValue(Grid.ColumnProperty, randomValue.Next(0, 6)); }