sherman89 / WpfReporting

How to create paginatable & printable XAML documents using WPF controls, plus other useful features such as an MVVM dialog service. This repository is a reference for myself for future WPF development!
MIT License
13 stars 6 forks source link

Exception : "Tried to populate ItemsControls, but not a single item had enough space. " #3

Open smsaleem opened 2 years ago

smsaleem commented 2 years ago

Dear Sherman,

Thanks for sharing insightful code.
It works as a charm in table / grid layout when height of a text element is less than available / remaining page height.

However, when repot is in letter-layout which is composed of multiple paragraphs, when height of text increases remaining page height, following exception is thrown in the code -

Tried to populate ItemsControls, but not a single item had enough space. This can be caused by bad XAML or a given page size that is too small to fit row content.

Can you help to resolve the issue.

Regards,

sherman89 commented 1 year ago

Hi @smsaleem could you please provide example XAML for me to test with? Apologies for late response, been extremely busy with family and work.

This can happen if the list cannot fit at least 1 fully visible item in the page. The paginator works by filling the list one by one, each time checking if the new item is fully visible, and if not, signals that a new page is needed. If even the first item doesn't fit, you get an empty list, and this exception.

I wouldn't be surprised if there was a bug, this is hardly production ready code 😄

smsaleem commented 1 year ago

Dear Sherman,

Please accept apology for late response.

Example application is uploaded as a zip file.

WpfReporting-master.zip

In this example application, which uses existing code, two json data files are added for two reports, one works while the other throws this exception.

For ready reference XAML used in this example is as follows -

<UserControl x:Class="Sherman.WpfReporting.Gui.Reports.StoryBookView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:lib="clr-namespace:Sherman.WpfReporting.Lib;assembly=ReportPaginator" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:reports="clr-namespace:Sherman.WpfReporting.Gui.Reports" xmlns:sys="clr-namespace:System;assembly=System.Runtime" d:DesignHeight="400" d:DesignWidth="800" mc:Ignorable="d">

Please see if you can help.

Regards,