如果您的其他窗口小部件的背景颜色不正确,则可以将其放置在事件框窗口小部件中,因为该窗口小部件具有背景,而其他窗口小部件可能没有背景.自2007年以来,您就可以在Mono电子邮件线程中搜索这种情况.Im trying to change the color of button widget in GTK# by usingbutton1.ModifyBase(Statetype.Normal,new Gdk.Color(1,1,1));This is called from another button click event,but the widget color is not updatedwhy is this? 解决方案 Instead of the 'flaky' ModifyBase, you can just use the ModifyBG method, same params are passed. button1.ModifyBG(Statetype.Normal,new Gdk.Color(1,1,1));BTW, I say flaky since you are dealing with GTK2.x under Mono GTK# and there are tons of issues on both sides when it comes to 'theming' and Mono. GTK3 has a consist model using a CSS approach, but the Mono distro is stuck on GTK2. You can search for theming GTK 2.x if you wish to theme/colorize your application the GTK way. Note: If using MonoDevelop/XS, make sure you routinely test/run it outside of the IDE as the app theming will change (this is really apparent on OS-X and again, an issue that goes back years and years).If you have other widgets that do not 'behave' correctly in their background colors, you can place them within an eventbox widget as that widget has a background while others might not. You can search for this condition within the Mono email threads as it has been around since 2007. 这篇关于GTK C#小部件更改颜色不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-30 12:52