I have a xamDataGrid which needs some custom UI controls overlaid on top of the grid. To that end, I have customized the template of the RecordListControl
<Style TargetType="{x:Type igDP:RecordListControl}" BasedOn="{StaticResource {x:Type igDP:RecordListControl}}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:RecordListControl}"> <Border Background="{TemplateBinding Background}"> <Grid > <ScrollViewer CanContentScroll="true" Focusable="false" HorizontalScrollBarVisibility="{TemplateBinding HorizontalScrollBarVisibility}" VerticalScrollBarVisibility="{TemplateBinding VerticalScrollBarVisibility}"> <my:CustomPanel> <my:CustomControl1/> <my:CustomControl2/> <my:CustomControl3/> <ItemsPresenter></ItemsPresenter> <!-- ItemsPresenter for the data grid -> </my:CustomPanel> </ScrollViewer> </Grid> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> Then, I implemented the necessary Measure and Arrange logic in my CustomPanel to arrange the custom controls on top of the ItemsPresenter in the way that I need. This is actually working pretty well, except I am having a problem that seems to be virtualization-related. Inside the ItemsPresenter, I am seeing one DataRecordPresenter for each item in the XamDataGrid ItemsSource. However, most (beyond the first few) of the DataRecordPresenter have actual size = 0. This is happening despite having AllowCellVirtualization="false" and AllowLabelVirtualization="false" in my FieldSettings and RecordContainerGenerationMode="PreLoad", RecordLoadMode="PreloadRecords", CellContainerGenerationMode="PreLoad", ScrollingMode="Immediate" properties in the XamDataGrid.
So I have a few questions. 1) Is this the right overall design to accomplish what I need to do? 2) How can I get all the DataRecordPresenters to be realized with correct height and width? Is the fact that my custom panel is not a ScrollViewer related to the problem I am facing?
Hello Adit,
I can say that it is not possible to create an image of an elemnts that are currently not rendered and that are not in view, like the Records in the XDG.
Hi stefen,
I set the data presenter pre loaded and check actual height 0 as what Brian did. I want the total height of grid.
In my case i am generating image of grid. But it takes only the visible area like first 10 or 15 DataRecordPresenters but not getting all Data Record.
because when i get Actual Height of Xmadatagrid it is just the visible area height.
here is my code what i used to generate BitmapSource
public static BitmapSource RenderToBitmap(FrameworkElement target) { Rect bounds = VisualTreeHelper.GetDescendantBounds(target); RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)target.ActualWidth, (int)target.ActualHeight, 96, 96, PixelFormats.Pbgra32);
DrawingVisual visual = new DrawingVisual(); using (DrawingContext context = visual.RenderOpen()) { VisualBrush brush = new VisualBrush(target); context.DrawRectangle(brush, null, new Rect(new Point(), bounds.Size)); }
renderBitmap.Render(visual);
return renderBitmap; }
i just call RenderToBitmap(grid) it return me image with viewable section. I want image of whole grid (all data record presenters).
Thanks
Adit
Hello Brian,
As I said in my previous post, this behavior occurs by design. Despite this you can still access the controls that are inside the DataRecordPresenter. Also after some research Turn off virtualization completely has been determine as a new Product Idea. I have sent your Product Idea directly to our product management team. Our product team chooses new Product Ideas for development based on popular feedback from our customer base. Infragistics continues to monitor application development for all of our products, so as trends appear in requested ideas, we can plan accordingly.
We value your input, and our philosophy is to enhance our toolset based on customer feedback. If your idea is chosen for development, you will be notified at that time. Your reference number for this Product Idea is PI12110111
If you would like to follow up on your Product Idea at a later point, you may contact Developer Support management via email. Please include the reference number of your Product Idea in the subject and body of your email message. You can reach Developer Support management through the following email address: dsmanager@infragistics.com
In my case, the DataRecordPresenters are presenting some custom controls and the overlays I mentioned before need all the custom controls to be realized. What I'm not understanding so far is why the records are getting virtualized using the example you provided, but they are not if I remove the custom control template for the RecordListControl. In other words, why does this template cause the records get virtualized:
<ControlTemplate TargetType="{x:Type igDP:RecordListControl}">
<Border Background="{TemplateBinding Background}"> <Grid ><ScrollViewer
CanContentScroll="true" Focusable="false" HorizontalScrollBarVisibility="{TemplateBinding HorizontalScrollBarVisibility}" VerticalScrollBarVisibility="{TemplateBinding VerticalScrollBarVisibility}"><StackPanel Orientation="Vertical"><ItemsPresenter RenderTransform="{TemplateBinding ScrollableElementTransform}">
</ItemsPresenter></StackPanel>
</ScrollViewer>
</Grid> </Border> </ControlTemplate>
While this template does not virtualize the records:
<Border Background="{TemplateBinding Background}"><Grid ><ScrollViewer
CanContentScroll="true"Focusable="false"HorizontalScrollBarVisibility="{TemplateBinding HorizontalScrollBarVisibility}"VerticalScrollBarVisibility="{TemplateBinding VerticalScrollBarVisibility}"><ItemsPresenter RenderTransform="{TemplateBinding ScrollableElementTransform}">
</ItemsPresenter></ScrollViewer>
</Grid></Border></ControlTemplate>
What is it about placing the ItemsPresenter inside a Panel (a StackPanel, or any other panel I have tried) that causes the records to get virtualized? If you can help me understand this, maybe I can find a suitable workaround. Thanks.
I was able to reproduce your behavior and I can say that this is the designed beahavior. If you give us more details why do you need the DataRecordPresenters to be preloaded and what is the result you want to achieve, I can try to think of a possible solution for you.
Looking forward for your reply.