I have a readonly xamDataGrid that I want to use to display some rows. Rows are exceeding the height of the grid control but no scroll bars are visible. If I resize the window and make it larger, I can see all the records, but when it the window is smaller, some rows are clipped.
Here's my xaml code:
<vw:ReportView x:Class="Jimba.UI.View.SalesReport" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igdp="http://infragistics.com/DataPresenter" xmlns:fa="http://schemas.hightech.ir/wpf/2008/FarsiLibrary" xmlns:con="clr-namespace:Jimba.UI.Converter" xmlns:vw="clr-namespace:Jimba.Infrastructure.View;assembly=Jimba.Infrastructure"> <UserControl.Resources> <con:DateTimeConverter x:Key="DefaultDateConverter" /> </UserControl.Resources> <StackPanel Orientation="Vertical"> <Expander Header="{LocText Key=ReportFilter}" VerticalAlignment="Top" Margin="10" IsExpanded="True"> <StackPanel Margin="10"> <StackPanel Orientation="Horizontal" Margin="2"> <TextBlock Text="{LocText Key=DateFrom, Suffix=':'}" Width="80" VerticalAlignment="Center" FontFamily="{DynamicResource MessageFontFamily}" /> <fa:FXDatePicker SelectedDateTime="{Binding ReportDateFrom}" ShowEmptyButton="False" MaxDate="2999/01/01" MinDate="2000/01/01" /> </StackPanel> <StackPanel Orientation="Horizontal" Margin="2"> <TextBlock Text="{LocText Key=DateTo, Suffix=':'}" Width="80" VerticalAlignment="Center" FontFamily="{DynamicResource MessageFontFamily}" /> <fa:FXDatePicker SelectedDateTime="{Binding ReportDateTo}" ShowEmptyButton="False" MaxDate="1/1/2999" MinDate="1/1/2000" /> </StackPanel> </StackPanel> </Expander> <igdp:XamDataGrid x:Name="PurchaseList" FontFamily="Tahoma" AutoFit="True" GroupByAreaLocation="None" ScrollingMode="Deferred" DataSource="{Binding TransactionsData}" Margin="5"> <igdp:XamDataGrid.FieldLayouts> <igdp:FieldLayout> <igdp:FieldLayout.Settings> <igdp:FieldLayoutSettings AutoGenerateFields="False" AllowAddNew="False" AllowDelete="False" /> </igdp:FieldLayout.Settings> <igdp:FieldLayout.Fields> <igdp:Field Name="PurchaseDate" Label="{LocText Key=DateAndTime}" Converter="{StaticResource DefaultDateConverter}" ConverterParameter="g"> <igdp:Field.Settings> <igdp:FieldSettings AllowEdit="False" AllowSummaries="True" /> </igdp:Field.Settings> </igdp:Field> <igdp:Field Name="Product" Label="{LocText Key=Product}"> <igdp:Field.Settings> <igdp:FieldSettings AllowEdit="False" AllowSummaries="True" /> </igdp:Field.Settings> </igdp:Field> <igdp:Field Name="Quantity" Label="{LocText Key=Quantity}"> <igdp:Field.Settings> <igdp:FieldSettings AllowEdit="False" AllowSummaries="True" /> </igdp:Field.Settings> </igdp:Field> <igdp:Field Name="PaidValue" Label="{LocText Key=Total}"> <igdp:Field.Settings> <igdp:FieldSettings AllowEdit="False" AllowSummaries="True" /> </igdp:Field.Settings> </igdp:Field> <igdp:Field Name="Purchaser" Label="{LocText Key=Customer}"> <igdp:Field.Settings> <igdp:FieldSettings AllowEdit="False" AllowSummaries="True" /> </igdp:Field.Settings> </igdp:Field> </igdp:FieldLayout.Fields> </igdp:FieldLayout> </igdp:XamDataGrid.FieldLayouts> </igdp:XamDataGrid> </StackPanel></vw:ReportView>
That is because a StackPanel will measure its children with infinity in the direction of the orientation. So if the orientation is vertical, the children are measured with an infinite height and then arranged with that height. So a list control like a grid or listbox will be as tall as needed to show all their children. If those children happen to be taller than the containing StackPanel then they will just be clipped.
Strangely, I noticed the other grid (in another Usercontrol) works just fine. After comparing two xaml codes I found out that changing the parent container from StackPanel to Grid will solve this issue.
How does scroll bars not being visible has anything to do with parent container type, I don't know.