Border 控件的 BorderThickness 不起作用

BorderThickness of Border control doesn't work

我定义了以下数据模板:

                    <dxg:TableView.DataRowTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical">
                            <Border BorderThickness="0" BorderBrush="#D0C9A0" Style="{StaticResource borderStyle}">
                                <dx:MeasurePixelSnapper>
                                    <ContentControl Content="{Binding}" ContentTemplate="{Binding View.DefaultDataRowTemplate}"/>
                                </dx:MeasurePixelSnapper>
                            </Border>
                        </StackPanel>
                    </DataTemplate>
                </dxg:TableView.DataRowTemplate>

并且我想在行获得焦点时应用此样式:

        <Style TargetType="Border" x:Key="borderStyle">
        <Setter Property="BorderThickness" Value="0"/>
        <Style.Triggers>
            <Trigger Property="dxg:GridViewBase.IsFocusedRow" Value="True">
                <Setter Property="BorderThickness" Value="4"></Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

为什么不起作用?我不明白为什么 Trigger 会被执行。有什么解决办法吗?

<Border BorderThickness="0" ...> 设置的本地 属性 值的优先级高于样式设置的任何值。因此,触发器设置的值将被静默忽略。

只需删除 BorderThickness 分配:

<Border BorderBrush="#D0C9A0" Style="{StaticResource borderStyle}">
    ...
</Border>

参见Dependency Property Value Precedence