如何覆盖 BorderBrush?

发布于 2024-12-05 22:48:03 字数 164 浏览 8 评论 0原文

我有一个文本框的样式,我想在应用程序层覆盖这种样式的 BorderBrush。

我尝试过:d:LayoutOverrides="BorderBrush"。但这行不通。

我想要相同的样式,但使用红色的 BorderBrush。

请问我该怎么做?

谢谢。

I have a style to a textbox, and I want in the application layer override de BorderBrush of this style.

I tried: d:LayoutOverrides="BorderBrush". But this doesn't work.

I want the same style, but with a red BorderBrush.

How can I do this please?

Thank you.

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

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

发布评论

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

评论(2

橘香 2024-12-12 22:48:03

正如您提到的在标签中混合:您可以右键单击文本框搜索模板并从现有模板中创建新模板(编辑副本)。这将提取文本框的完整定义,您可以在那里更改您想要的所有内容。

以下是分步说明的所有内容:创建或编辑控件模板

as you mentioned Blend in your tags: you can right-click a textbox search templates and create new ones from the existing (Edit a Copy). This will extract the complete definition of the textbox and you can change everything you want there.

Here is everything explained step-by-step: Create or edit a control template

半衬遮猫 2024-12-12 22:48:03

将您的样式基于旧的样式并更改边框画笔

<Style TargetType="TextBox" BasedOn="{StaticResource oldBrushKey}">
    <Setter Property="BorderBrush" Value="Red" />
</Style>

,或者如果它是您想要覆盖的默认样式,请使用

BasedOn="{StaticResource {x:Type TextBox}}"

Base your style on your old one and change the Border brush

<Style TargetType="TextBox" BasedOn="{StaticResource oldBrushKey}">
    <Setter Property="BorderBrush" Value="Red" />
</Style>

or if it's the default style you want to override use

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