I’ve placed a XamDataGrid with both Height & Width set to Auto and the MaxHeight and MaxWidth set to Infinity inside a UserControl Object, That is itself placed as a Child of a WrapPanel in a ScrollDoc object. I then format and add multiple rows of Data programmatically to the XamDataGrid.
I discovered that after a relatively small number of rows the XamDataGrid automatically creates a ScrollBar, and doesn’t display all the records. My Clients want one scroll bar for all records with none hidden;
So I then set the Max Height to a large value (in this case 100,000) and while this forced the data grid to display fully, it then however lead to an issue of Out of Memory Exceptions being thrown with all my windows in the program being deleted and redrawn in no particular order;
In this instance there were 56 XamDataGrids and 8557 rows between all of them.
Is there a way to Display all the rows within the XamDataGrids like my Client wants, without causing Out of Memory Exceptions?
Hello,
I am sorry, I did not understand your scenario completely. I am not sure why you set MaxHeight/MaxWidth as well as Height and Width properties, as they are set to Infinity by default. According to your description, both the XamDataGrid and the ScrollViewer have scrollbars?
I also do not see a reason why the OutOfMemoryException is thrown. Have you set the RecordContainerGenerationMode to PreLoad?
If you have a mock application that reproduces the scrollbar issues, please attach it to your next post, or a screenshot.
Thanks.
I guess I skipped a few things, so sorry about that. In my program the XamDataGrid can be variable size but I need them to display all records without a scroll bar; this is because the old (10+ year old) program that is being rewritten just uses a text field to show all the data and the users want it to mimic that. So the program go to a loads each XamDataGrid with in a UserControl and slaps that into a scrolldoc to mimic the behavior. Well if I leave the max height at Infinity, then the XamDataGrid wants to scroll no matter what, the one way I found to force it to not scroll is to set the MaxHeight to a very large number. If I set it to a very large number I then get the Out of Memory with large data sets.
I have tried the following combinations on my grid:
RecordLoadMode="LoadOnDemand/ PreloadRecords " RecordContainerGenerationMode="Virtualize/ LazyLoad / Recycle / PreLoad " MaxHeight="100000" =FAIL with big data sets, but works the way my users want.
RecordLoadMode="LoadOnDemand/ PreloadRecords " RecordContainerGenerationMode="Virtualize/ LazyLoad / Recycle / PreLoad " MaxHeight=" Infinity " =Loads, but does not work in the way my users want.
The screenshot if I do not set RecordLoadMode="PreloadRecords" RecordContainerGenerationMode="PreLoad" MaxHeight="Infinity"
Unless I'm misunderstanding your scenario, WPF is not meant to deal with what you are trying. To understand what I mean, let's evaluate your situation. In a simple case where you had no filter/summary/fixed button and had about 4 fields per field layout, each header presenter would have about 130 elements (for the labels). A simple datarecord element for those 4 fields could be about 80 elements. So if you have 56 grids and you assume you have 1 header per grid, that's 7280 elements. Now add in 684000 for all 8557 records. (Remember virtualization won't help here because you're sizing the control based on the contents - i.e. showing all the records - and so nothing is virtualized) So that's about 690,000 elements. This is not considering all the remaining chrome/borders/etc within the grid, the groupby area, the other elements in your window including elements that may be collapsed like the scrollbars in the grids and you would have over 700,000 that are being measured/arranged/rendered. If you try adding any 700000 elements to a window and you will get an out of memory exception. I think your going to have to reconsider this approach and provide an alternate layout for your end user.
BTW, the reason the scrollbar shows up when you have no max height is because by default elements within a stackpanel will be sized based on their content and therefore the control will get measured with an infinite height. When that happens the control uses the value of the viewsettings' HeightInInfiniteContainers which when unspecified defaults to the virtual screen height.
I do not want to scroll using the xamdatagrid; I want them to be lined up one after an other in so that I only use one scroll bar for all the controls.
Thanks for the sceenshots and the additional info. There is a way to force the VerticalScrollBar to be hidden, but how are you going to scroll the XamDataGrid's Records?
<Style TargetType="{x:Type igDP:RecordListControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:RecordListControl}">
<ScrollViewer
RenderTransform="{TemplateBinding FixedNearElementTransform}"
CanContentScroll="true"
Focusable="false"
HorizontalScrollBarVisibility="Visible"
VerticalScrollBarVisibility="Hidden">
<ItemsPresenter RenderTransform="{TemplateBinding ScrollableElementTransform}"/>
</ScrollViewer>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>