WPF Datagrid - Not showing any Scrollbar
To sum up comments your control looks fine which would suggest that the problem is somewhere up the visual tree. Most likely InventoryList
, or one of its parents, it's placed in control that gives its children infinite amount of space to grow like StackPanel
, ScrollViewer
or Canvas
. Because of that DataGrid
can grow to accommodate all item hence not scroll bar is visible.
Remove that control or replace it with one that limits the size of its children
Set The Property in datagrid
<DataGrid AutoGenerateColumns="False" Grid.Column="0" Grid.Row="0" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto"></DataGrid>
you can use the scrollviewer like
<ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto"> <DataGrid ItemsSource="{Binding PresentableInventoryItems}" VerticalAlignment="Stretch" AutoGenerateColumns="False" Height="500"> <DataGrid.Columns> <DataGridTextColumn Header="Produkttitel" Width="350" Binding="{ Binding ProductTitle}"/> <DataGridTextColumn Header="Sku" Width="100" Binding="{ Binding Sku}" /> <DataGridTextColumn Header="Menge" Width="60" Binding="{ Binding Quantity}" /> </DataGrid.Columns> </DataGrid></ScrollViewer>
If I have define the height of Datagrid the Scrollbar visible.