Adjust a Control Template and still respect the Theme of the OS?

巧了我就是萌 提交于 2019-12-24 04:13:06

问题


In WPF how do I modifiy the template for a standard control in a way that it will respect the current Theme of the Operating System later on? If I just "edit a copy" of the template in blend, it will just give me the template of the currently running theme. Is this correct? So when I apply the modified template and run the app on different themes it will always look the same.

For custom controls and even for data templates the problem is similar. How do I provide a template that respects all possible themes of the OS?


回答1:


I don't think this is possible. If you create a template for a control you are replacing the entire control template.

You can use styles to just configure exposed properties, but if you change the template, you are no longer related to the theme. You can create a separate override of the template for each theme, but you would have to define each explicitly and if Microsoft created a new theme you would have to create a new template to match it.

See my own related question - When overriding WPF templates do I have to override each theme’s template separately?



来源:https://stackoverflow.com/questions/980055/adjust-a-control-template-and-still-respect-the-theme-of-the-os

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!