WPF DataGrid horizontal scrollbar not showing

后端 未结 7 1923
眼角桃花
眼角桃花 2021-02-05 08:14

I have created simple DataGrid with 4 columns, which go outside the bounds of DataGrid, and horizontal scrollbar is not showing. I tried setting width to each column but nothing

7条回答
  •  清歌不尽
    2021-02-05 08:37

    Set Datagrid's properties as CanUserAddRows="True" IsReadOnly="True" and wrap it with ScrollViewer. CanUserAddRows gives you an empty row. Empty row retains scrollbar. IsReadOnly hides the empty row since it's readonly.

    Downside is, when you scroll vertically datagrid headers would be hidden.

提交回复
热议问题