我有一个包含25个按钮的网格控件(该网格仅包含按钮)。每个按钮都设置了相同的图像,如下所示:
ImageBrush brush = new ImageBrush();
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource = new Uri(@"pack://application:,,,/Images/notexplored.jpg", UriKind.RelativeOrAbsolute);
bitmap.EndInit();
brush.ImageSource = bitmap;
foreach (UIElement uie in myGrid.Children)
{
var temp = uie as Button;
temp.Background = brush;
}
我的问题是,当我悬停在按钮上时,会出现这种情况(这是一个短视频,展示了问题):https://www.dropbox.com/s/jb8fb29lrpimue5/ButtonIssue.avi。如何纠正这个问题?将图像应用为按钮的背景后,如果我在按钮上悬停,我不想看到默认的按钮背景(外观),而是应用的图像。请帮忙解决。