Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't see complete stackpanel in printout
    primarykey
    data
    text
    <p>I've been trying to print out my data column headers by using stackpanels which is working and I get my printout. The only problem is that my stackpanel gets cut off after a fixed width and I'm not sure which property is responsible for it. It's like the printer only sees a rectangular limit over my stackpanel that has width shorter than my stackpanel and only prints what is in the rectangle. Can't really explain it too well without a picture but I don't have a scanner. </p> <p>Heres my code for it:</p> <pre><code>private void btnPrint_Click(object sender, RoutedEventArgs e) { PrintDialog dialog = new PrintDialog(); if (dialog.ShowDialog().GetValueOrDefault()) { List&lt;Result&gt; results = vm.ObsResults.OrderByDescending(r =&gt; Convert.ToDouble(r.SchedulingRate)).ToList(); var propList = typeof(Result).GetProperties().ToList(); int maxRowsPerPage = 42; var pgCnt = results.Count / maxRowsPerPage; XpsDocumentWriter docWriter = PrintQueue.CreateXpsDocumentWriter(dialog.PrintQueue); PrintTicket ticket = new PrintTicket(); ticket.PageOrientation = PageOrientation.Landscape; for (int pgNum = 0; pgNum &lt;= pgCnt; pgNum++) { //Title Canvas c = new Canvas(); c.Width = 1024; c.Height = 768; TextBlock tbTitle = new TextBlock(); tbTitle.Text = " Results " + vm.ObsDate.ToString("MM/dd/yyyy"); tbTitle.FontSize = 16; Canvas.SetLeft(tbTitle, 20); Canvas.SetTop(tbTitle, 10); c.Children.Add(tbTitle); //Column Headers StackPanel sp = new StackPanel() { Orientation = Orientation.Horizontal , Width = 885}; sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "Unit Name", Width = 150, Background = new SolidColorBrush(Colors.LightBlue) }}); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "Unit ID", Width = 65, Background = new SolidColorBrush(Colors.LightBlue) }}); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "Schedule", Width = 65, Background = new SolidColorBrush(Colors.LightBlue) }}); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "TPS", Width = 25, Background = new SolidColorBrush(Colors.LightBlue) }}); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "TTS", Width = 35, Background = new SolidColorBrush(Colors.LightBlue) }}); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "Min Run", Width = 50, Background = new SolidColorBrush(Colors.LightBlue) }}); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "Schd RT", Width = 50, Background = new SolidColorBrush(Colors.LightBlue) }}); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "MW", Width = 35, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "00", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "01", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "02", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "03", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "04", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "05", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "06", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "07", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "08", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "09", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "10", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "11", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "12", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "13", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "14", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "15", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "16", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "17", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "18", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "19", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "20", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "21", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "22", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 0, 1), Child = new TextBlock() { Text = "23", Width = 15, TextAlignment = TextAlignment.Center, Background = new SolidColorBrush(Colors.LightBlue) } }); sp.Children.Add(new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1, 1, 1, 1), Child = new TextBlock() { Text = "Constraint", Width = 100, Background = new SolidColorBrush(Colors.LightBlue) } }); Canvas.SetLeft(sp, 20); Canvas.SetTop(sp, 35); c.Children.Add(sp); int idxStart = pgNum * maxRowsPerPage; int idxEnd = Math.Min(results.Count, idxStart + maxRowsPerPage); int topMargin = 3; } c.Measure(new Size(Int32.MaxValue, Int32.MaxValue)); c.Arrange(new Rect(new Point(0, 0), c.DesiredSize)); FixedPage fxdPg = new FixedPage(); fxdPg.Children.Add(c); PageContent pgContent = new PageContent(); ((IAddChild)pgContent).AddChild(fxdPg); fxdDoc.Pages.Add(pgContent); } docWriter.WriteAsync(fxdDoc, ticket); } } </code></pre> <p>It looks like this where it gets cut off:</p> <pre><code>00 | 01 | 02 | ... |18 | 19 | 2/ &lt;cut off. </code></pre> <p>No 21, 22, 23, headers.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload