【发布时间】:2013-12-15 22:27:59
【问题描述】:
我想在我的 WPF 应用中手动更改按钮的背景。
我有一张图片导入到我的资源中,我想做:
MyButton.Background = MyProject.Properties.Resources.myImage;
但我得到了错误:
无法将 system.drawing.bitmap 隐式转换为 media.brush
我该怎么做??
【问题讨论】:
-
Background 是错误的属性,你需要像 BackgroundImage 这样的东西
-
@CSharpie 你错了,
Background是正确的属性。您需要将其设置为ImageBrush。 -
哦,好的。今天学到了新东西:)