WPF:我有一个按钮,图像是在c#
后面的代码中设置的 btn.Content = new Image
{
Source = new BitmapImage(new Uri(MasterVariables.applicationPath + "Normal.png")),
Stretch = Stretch.Fill,
};
现在问题是在按钮背景颜色设置为蓝色但我在mouse_enter事件中更改图像
btn.BorderThickness = new Thickness(0);
btn.Style = (Style)FindResource(ToolBar.ButtonStyleKey);
btn.Background = Brushes.White; btn.BorderBrush = Brushes.Transparent;
btn.Content = new Image
{
Source = new BitmapImage(new Uri(MasterVariables.applicationPath + "Hover.png")),
Stretch = Stretch.Fill,
};
图像发生了变化,但在鼠标中,背景以蓝色突出显示
答案 0 :(得分:0)
更新您的样式以在MouseOver上触发背景:
<Style.Triggers>
<Trigger Property='IsMouseOver' Value='True'>
<Setter Property='Background' Value='White' />
</Trigger>
</Style.Triggers>
答案 1 :(得分:0)
试试这个
public partial class YourContext: DbContext
{
static YourContext()
{
Database.SetInitializer<YourContext>(new CreateDatabaseIfNotExists<YourContext>());
}
}
更多信息请参阅此网站