0
我目前正在尝试为我的控件创建一个样式,它根据控件的只读状态更改控件的外观。如何根据其他样式属性设置样式属性值?
我有触发器正常工作,但我想改变一些属性取决于其他属性的值。
举个例子,拿TextBox控件,这里是基本样式触发I定义:
<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>
风格做工精细,并且该文本框与接近TextBlock的样式呈现只读的时候模式。但我想定义Padding
属性的值,具体取决于Padding
和BorderThickness
的初始值。
我该如何做到这一点?
我认为这是重复的:http://stackoverflow.com/questions/1351635/can-my-wpf-style-setter-use-a-templatebinding。尝试使用那里的分辨率。 – milanio 2013-04-11 12:30:46