WPF DataGrid horizontal scrollbar not showing

后端 未结 7 2047
眼角桃花
眼角桃花 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:30

    I also very much dislike this behavior, since I use header filters. My "hack" is much easier than the above: simply place the data grid inside a new ScrollViewer with HorizontalScrollBarVisibility=Auto and VerticalScrollBarVisibility=Disabled (the DataGrid already handles that one fine). Like so:

    
        
            ...
        
    
    

    Sure, it's more controls on the page, but a lot easier than the hacky code above. So far I haven't found a way to make the data grid do this automatically.

    The side effect of this solution may be the vertical scrollbar hidden until you scroll to the right.

提交回复
热议问题