【发布时间】:2017-05-23 17:46:29
【问题描述】:
我目前正在学校做一个项目。
我正在制作扫雷。下面是它的外观:
游戏网格由背景中带有图像的按钮组成。 它工作得很好,除非鼠标悬停在按钮上;背景变为浅蓝色:
这是我用来定义按钮的代码:
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
Button temp = new Button();
temp.Background = situationImages[0];
temp.Height = 16;
temp.Width = 16;
temp.Click += window.button_Click;
temp.MouseRightButtonUp += window.button_Right_Click;
gameGrid.Children.Add(temp);
Grid.SetRow(temp, j);
Grid.SetColumn(temp, i);
MainWindow.buttons[i, j] = temp;
}
}
到目前为止,我看到的所有解决方案都是用 XAML 编写的,但这对我的情况没有帮助。
如何以编程方式将其更改为当我悬停鼠标时它不会改变背景的状态?
【问题讨论】:
-
你有什么问题?
-
如何以编程方式将其更改为当我悬停鼠标时不会改变背景的状态@Bojje
-
查看我编辑的答案。为您提供任何您想要的背景颜色