覆盖默认样式/控件模板是否会破坏主题?

发布于 2024-08-07 12:23:42 字数 146 浏览 2 评论 0原文

当我使用“编辑副本”覆盖混合中标准 WPF 控件的默认样式/控件模板而不修改它(仅创建 if 的本地副本)时,这在某些情况下是否会破坏主题?换句话说,不同的主题是否为标准控件提供不同的控件模板和/或样式定义?如何确保我的样式/控件模板尊重主题?

When I override the default style/controltemplate of a standard WPF control in blend using "Edit a Copy" without modifying it (just creating a local copy of if), will this already break theming in some scenarios? In other words, do different themes provide differnt controltemplate- and/or styledefinitions for the standard controls? How can I make sure that my styles/controltemplates respect theming?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

归途 2024-08-14 12:23:42

是的,这打破了主题;

是的,不同的主题提供不同的控件样式。如果您有 MS Blend,您可以在 Blend 的文件夹中找到它们(例如在 C:\Program Files\Microsoft Expression\Blend 3\SystemThemes\Wpf 中)。

为了尊重主题,您还应该为控件的每个主题创建一种样式。有许多资源关于自定义控件和主题支持。仅提一个: WPF:根据系统主题更改控件样式

Yes, this breaks theming;

Yes, different themes provide different controls styles. If you have MS Blend you can find them in Blend's folder (e.g. in C:\Program Files\Microsoft Expression\Blend 3\SystemThemes\Wpf )

To respect theming, you should also create one style per theme for your control. There are many resources out there on custom control and themes support. Just to mention one: WPF: Changing control style based on the system theme

菊凝晚露 2024-08-14 12:23:42

作为开发人员,您希望根据控件的功能来编写控件。到处使用默认的控件样式。然后让专业人士处理它的图形设计方面。如果您覆盖控件的 ControlTemplate,那么您已经在忙于主题化了。

如果您确实使用 ControlTemplates 尝试并保持标准方法,否则一旦图形设计师开始开发应用程序,他/她就会对您发誓:)

主题是针对单个控件并重新定义其外观的样式集合-感觉。 为其提供 ControlTemplate 的任何控件要么不会应用它,要么与主题包不一致(取决于您是通过 x:Name 还是通过 Type 访问主题)。

您 不过还好。您可以安全地执行此操作,而不必担心主题干扰。

As a developer you want to author your controls in terms of their functionality. Use default control styles everywhere. Then let the pro's handle the graphic design aspect of it. If you override a control's ControlTemplate you are busy with theming already.

If you do muck around with ControlTemplates try and keep with the standard approach, otherwise once the graphic designer starts working on the application he/she's going to swear at you :)

Themes are collections of styles that target individual controls and redefine their look-and-feel. Any Control for which you've provided a ControlTemplate will either not have it applied or won't be consistent with the theme-pack (depending on whether you access the theme by x:Name or by Type)

If you override DataTemplates, you are fine however. This you can safely do without worrying about theming interference.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文