DataGrid row selection not working when padding is added to cells

前端 未结 1 677
醉酒成梦
醉酒成梦 2021-01-15 00:26

DataGrid control in WPF is behaving weird. When I click on a row it should be selected. There is a problem when I click on cell border or row border. It simply does nothing

相关标签:
1条回答
  • 2021-01-15 00:56

    Since you hadn't posted any xaml, or a picture of how your datagrid looks. It's hard to pint point the problem.

    However, This might be caused by a Hit Test failing. The mouse hit test detects an element by the matrix of colored pixels which represent it.

    Try coloring all the pixels by setting the background to Transparent. Transparent would not effect how your row looks and would color it for the Hit test :

    <DataGrid>
        <DataGrid.RowStyle>
            <Style TargetType="DataGridRow">
                <Setter Property="Background" Value="Transparent" />
            </Style>
        </DataGrid.RowStyle>
    </DataGrid>
    
    0 讨论(0)
提交回复
热议问题