0
在ControlTemplate中我尝试使用二传手在DataTrigger修改在边境个别圆角半径的资源部分:问题设置CornerRadius的特定成员的风格二传手
<Style x:Key="SectionBorder" TargetType="{x:Type Border}" >
<Setter Property="CornerRadius" Value="5" />
<Style.Triggers>
<DataTrigger Binding="{Binding HasChildSection, RelativeSource={RelativeSource TemplatedParent}}" Value="True">
<Setter Property="(Border.CornerRadius).(CornerRadius.BottomLeft)" Value="0" />
<Setter Property="(Border.CornerRadius).(CornerRadius.BottomRight)" Value="0" />
</DataTrigger>
</Style.Triggers>
</Style>
这将生成编译器错误:
“无法解析样式属性'BottomLeft)'。验证拥有的类型是样式的TargetType,还是使用Class.Property语法指定属性。
WPF会因为CornerRadius属性名称和类型名称而变得困惑吗?或者我没有正确使用“Class.Property语法”?如果我只是使用“CornerRadius.BottomLeft”作为属性,我会在运行时得到一个XamlParseException,指出Property不能设置为null。
好的,我不知道Setters有这个限制。我认为它必须与动画相同,TargetProperty可以作为路径。我会尝试一下,如果我可以直接将角色设置在CornerRadius上。 – NPVN