开发者

Unique styles for focused / current row and selected rows in the WPF DataGrid

开发者 https://www.devze.com 2023-03-08 10:31 出处:网络
I\'m trying to style the focused/current row differently from the selected row(s) on the WPF datagrid, but can\'t figure out an elegant way to do so. The closest I have come up with is to use \"IsKeyb

I'm trying to style the focused/current row differently from the selected row(s) on the WPF datagrid, but can't figure out an elegant way to do so. The closest I have come up with is to use "IsKeyboardFocusWithin," but that disappears when the Datagrid itself loses focus. I'd like to somehow know from the style if the row is the one that contains CurrentCell and change the background color based on that. Is there any way to do so? Here's my current implementation using "IsKeyboardFocusWithin"

<Style x:Key="PlaylistDataGridRowStyle"
       TargetType="{x:Type DataGridRow}">
    <Style.Triggers>            
        <Trigger Property="IsSelected"
                 Value="True">
            <Setter Proper开发者_如何学运维ty="Background"
                    Value="#CB88AACD" />                
        </Trigger>
        <Trigger Property="IsKeyboardFocusWithin"
                 Value="True">
            <Setter Property="Background"
                    Value="#FF88AACD" />
        </Trigger>
    </Style.Triggers>
    <Setter Property="Background"
            Value="Transparent" />
    <Setter Property="BorderThickness"
            Value="0" />
</Style>
0

精彩评论

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

关注公众号