Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The direct cause of your problem is the lines:</p> <pre><code>taxCanvas.Height = GRight.ActualHeight; taxCanvas.Width = GRight.ActualWidth; </code></pre> <p>This sets a fixed size for your TimeAxis control, disabling any auto-resizing.</p> <p>Assuming your TimeAxis user control doesn't have any internal settings affecting measure, replacing the Height and Width settings with the following should cause your UserControl to resize automatically.</p> <pre><code>taxCanvas.HorizontalAlignment = HorizontalAlignment.Stretch; taxCanvas.VerticalAlignment = VerticalAlignment.Stretch; </code></pre> <p>This may not completely solve your problem however; your UserControl's desired size and layout size will be the same as that of the grid, but you will still need to manually resize the objects on your canvas. A Canvas doesn't have any provision for measure/arrange, so you'll have to handle this with code. Common techniques are:</p> <ol> <li>Wrapping the Canvas inside a ViewBox, which you already tried. You might try this again with the above lines changed.</li> <li>Adjusting the RenderTransform of the canvas using code or bindings (more efficient than adjusting LayoutTransform, and Canvas doesn't participate in layout anyway)</li> <li>Adjusting individual shape positions using code or bindings</li> </ol> <p>One gotcha to look out for: When you resize a canvas, it's contents aren't affected. So if you want to know whether your canvas is actually being resized, give it a background color. That way you won't waste time looking in the wrong place for a sizing problem.</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