最近做的项目用了个漂亮的开源UI库,结果项目临近结尾发现要支持.Net 3.5, 然而那个UI库却最低支持4.0。欲哭无泪,最后决定拿掉那个库,自己改改style得了。深刻的教训。
作为程序员一般都比较害怕搞界面,这下硬着头皮上,折腾折腾Blend,抄抄改改各种style,弄着弄着居然能看懂个大概了。最后在自己建立的UI库项目中如何组织资源有了一些总结,进入正题:
“Generic.xaml” 早有耳闻,不清楚究竟有什么作用。这次Google之,stackoverflow上早已有人发问。What is so special about Generic.xaml?
第一个答案清晰明了。
Every Control in WPF has a default Style that provides, among other things, the Control's default
ControlTemplate
. WPF looks for the default style in a special resource dictionary in the Themes folder in the same assembly as the control. The key for the default style is provided by theControl.DefaultStyleKey
dependency property, the default value of which is overridden in each sub-class of Contr