horizontal scrollbar not showing on datagrid when data is empty and headers do not fit on screen

前端 未结 2 1244
野性不改
野性不改 2021-01-29 16:40

I have tried the following :

ScrollViewer.CanContentScroll=\"True\"
ScrollViewer.HorizontalScrollBarVisibility=\"Visible\"

But it does not seem

2条回答
  •  再見小時候
    2021-01-29 17:23

    There must be a possibility to do it, because Extended WPF Toolkit has done it!


    Lets assume that you have e.g. this class:

    public class ExampleClass
    {
        public int LongPropertyNameA;
        public int LongPropertyNameB;
        public int LongPropertyNameC;
        public int LongPropertyNameD;
        public int LongPropertyNameE;
        public int LongPropertyNameF;
    }
    

    The normal approach looks like this:
    The Headers are hidden. The XAML Code looks e.g. like this:

    
    

    When you use the WPT Toolkit DataGrid Library (called Xceed.Wpf.DataGrid.dll) the grid looks like this with the scrollbars you want:
    The XAML Code looks e.g. like this:

    
    

    where xcdg is the namespace defined in the Window tag with this XAML Code:

    
    

    Conclusion:
    If you want it very easy download the Xceed WPF Toolkit and use the DataGridControl.

    • Download the .dll from the website (search the internet for the free version)
    • Add the .dll to the references of your project
    • Use and enjoy the DataGridControl

    Hope it helps!

提交回复
热议问题