Setting Foreground Color of Entire Window

后端 未结 4 861
小蘑菇
小蘑菇 2020-12-08 10:42

I\'d like to set the foreground (text) color to all of my elements You\'d think this would be easy, but it\'s not...


   <         


        
4条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 11:06

    Sadly the way the styles work in WPF you can't create a generic style on a parent class and have it apply to the sub-classed control.

    One thing you can do is create a base style that targets a base type with the property you want to set (like ContentControl) and then create a specific style for each control that is BasedOn that style. Here is an example: