Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF Canvas and Grid overlay
    text
    copied!<p>I have a <code>Grid</code> which represents some data, and I need a <code>Canvas</code> to overlay on top of it to layout some lines. The <code>Canvas</code> is inside it's own <code>UserControl</code>.</p> <p>The problem is that the <code>Canvas</code> and its contents should autoresize when the <code>Grid</code> resizes width and height.</p> <p>I added the <code>Canvas</code> inside a <code>ViewBox</code>, but it didn't do the trick. When the <code>Grid</code> resizes, the <code>Canvas</code> doesn't. The purpose of the <code>Canvas</code> is to overlay a ruler-like functionality on top of the grid.</p> <p>Looking forward for your solutions.</p> <p><strong>EDIT</strong></p> <p>I cannot use a style on the grid to replace the canvas, because the grid is showing different information than the canvas does. Think of it as chart, in which there are bar columns of different sizes (in my case the grid) and the days are lines in an overlay (just as a Gannt Chart)</p> <p>My code:</p> <pre><code> taxCanvas = new TimeAxis(); Grid.SetRowSpan(taxCanvas, GRightMain.RowDefinitions.Count); Grid.SetColumnSpan(taxCanvas, GRightMain.ColumnDefinitions.Count); Grid.SetColumn(taxCanvas, 0); Grid.SetRow(taxCanvas, 0); Grid.SetZIndex(taxCanvas, -1); taxCanvas.Height = GRight.ActualHeight; taxCanvas.Width = GRight.ActualWidth; GRightMain.Children.Add(taxCanvas); </code></pre> <p>TimeAxis is my canvas usercontrol, GRightMain is a grid which holds both my canvas and the grid with the content (Gright) in the same row and column. </p> <p>Hope this helps</p>
 

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