【发布时间】:2013-04-03 14:15:24
【问题描述】:
我目前正在尝试为我的控件创建一种样式,该样式根据控件的只读状态更改控件的外观。
我的触发器工作正常,但我想根据其他属性的值更改一些属性。
以TextBox控件为例,这是我定义的基本样式触发器:
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsReadOnly" Value="true">
<Setter Property="BorderThickness" Value="0,0,0,0" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Padding" Value="3,3,3,3" />
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
样式工作正常,并且在只读模式下,TextBox 以接近 TextBlock 的样式呈现。但我想根据Padding 和BorderThickness 的初始值来定义Padding 属性的值。
我怎样才能实现这种风格?
【问题讨论】:
-
我认为这是重复的:stackoverflow.com/questions/1351635/…。尝试使用那里的分辨率。