开发者

How to set the border for a WPF DataGrid Row which is currently having the focus

开发者 https://www.devze.com 2023-01-14 12:01 出处:网络
I want to set the border for a DataGrid Row which is currently having the focus. But not the seleced row because when the Multi selection is enabled for the datagrid then there is a chance that multip

I want to set the border for a DataGrid Row which is currently having the focus. But not the seleced row because when the Multi selection is enabled for the datagrid then there is a chance that multiple rows can be se开发者_StackOverflow社区lected.

I need a solution in XAML

Thanks in advance!


Add this to DataGridRow's style (either using Resources, or by setting DataGrid.RowStyle):

<Style TargetType="DataGridRow">
    <Style.Triggers>
        <Trigger Property="IsFocused" Value="true">
            <Setter Property="BorderBrush" Value="Red" />
            <Setter Property="BorderThickness" Value="1" />
        </Trigger>
    </Style.Triggers>
</Style>


Try IsKeyboardFocusWithin Property

    <Style.Triggers>
        <Trigger Property="IsKeyboardFocusWithin"
                 Value="True">
            <Setter Property="BorderBrush"
                    Value="Red" />
        </Trigger>
    </Style.Triggers>
0

精彩评论

暂无评论...
验证码 换一张
取 消