Making a row non-focusable in a WPF datagrid

前端 未结 1 1308
醉话见心
醉话见心 2021-01-14 16:41

I\'m trying to figure out how to make the rows in the following WPF DataGrid non-focusable. As you can see I tried adding a section t

相关标签:
1条回答
  • 2021-01-14 17:26

    Use IsHitTestVisible = False

    <DataGrid.Resources>
        <Style x:Key="NoFocusColumStyle" TargetType="{x:Type DataGridCell}">
            <Setter Property="IsHitTestVisible" Value="False"/>
        </Style>
    </DataGrid.Resources>
    

    Then apply the style to whatever columns you want to restrict focus for

    <DataGridTextColumn CellStyle="{StaticResource NoFocusColumStyle}" ... />
    
    0 讨论(0)
提交回复
热议问题