Problem setting specific member of CornerRadius in style setter

In the Resources section of a ControlTemplate I try to use a setter in a DataTrigger to modify individual corner radii on a Border:

<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>

This generates the compiler error:

"Cannot resolve the Style Property 'BottomLeft)'. Verify that the owning type is the Style's TargetType, or use Class.Property syntax to specify the Property."

Is WPF getting confused because CornerRadius is both property name and type name? Or am I not using "Class.Property syntax" properly? If I just use "CornerRadius.BottomLeft" for Property, I get a XamlParseException at runtime, stating that Property cannot be set to null.


That is not how setters work, you cannot set properties of properties, you only can replace the whole CornerRadius with a new one.

Property expects one property not a property path.

链接地址: http://www.djcxy.com/p/81354.html

上一篇: CSS:如何阻止文本占用超过1行?

下一篇: 在样式设置器中设置CornerRadius的特定成员时出现问题