我可以在 WPF 中部分应用 ControlTemplate 吗?

发布于 2024-08-05 20:42:28 字数 281 浏览 2 评论 0原文

我对 WPF 还很陌生,所以如果这是一个明显的问题,请原谅我。

我正在尝试修改使用 Divelements SandRibbon 库的现有代码库,但发现 GalleryButton 控件的行为不太符合我的要求。我想做的是更改 GalleryButton 排列图像和标签的方式,但保留所有触发器的默认“外观”,例如鼠标悬停等。

是否可以将 ControlTemplate 应用于控件的某些部分而不是其他部分?我想指定 GalleryButton 以与默认值不同的方式显示其“图像”和“文本”属性,但不触及其他任何内容。

I'm pretty green when it comes to WPF, so forgive me if this is an obvious question.

I'm trying to modify an existing code base that is using the Divelements SandRibbon libraries, but am finding that the GalleryButton control doesn't behave quite how I'd like. What I'd like to do is change the way GalleryButton arranges the image and label, but keep the default 'look' for all triggers such as mouse over etc.

Is it possible to apply a ControlTemplate to some parts of a control but not others? I want to specify that the GalleryButton displays its 'Image' and 'Text' properties differently than the defaults, but not touch anything else.

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

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

发布评论

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

评论(1

月竹挽风 2024-08-12 20:42:28

不幸的是,没有——要么全有,要么全无。然而,我之前使用过的一种解决方案是简单地子类化控件并更改 OnApplyTemplate 后面代码中的布局。

Unfortunately no -- it's all or nothing. However, one solution I've used before is to simply sublass the control and alter the layout in code behind in OnApplyTemplate.

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