M
M
Mikhail2017-12-31 18:43:03
WPF
Mikhail, 2017-12-31 18:43:03

How to stretch a canvas element to its entire remaining width?

Hello. I am writing a desktop application for Windows using WPF. The layout is something like this:

<StackPanel Orientation="Horizontal">
    <StackPanel Orientation="Vertical">
    </StackPanel>

     <Canvas RenderTransformOrigin="0.5, 0.5">
         <Canvas.RenderTransform>
              <ScaleTransform ScaleY="-1" />
         </Canvas.RenderTransform>
     </Canvas>
</StackPanel>

I would like the Canvas to take up all the remaining available space in width and height. How to implement it?
As I understand it, it automatically takes all the remaining space in height, if you specify the width.
Link to the layout code
A link to a gif that shows how the element behaves at the specified width, but not the specified height. I would like the same effect with horizontal resizing

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2018-01-01
@mak_ufo

Turn a horizontally oriented StackPanel i.e. the one in which you have the canvas in the DockPanel (the Orientation tag will need to be removed). Then your canvas, as the last of the children, will take up all the remaining available area (default behavior). Plus, it will be logical - after all, your control controls should be docked on the left, so it's more logical to use DockPanel.
Happy New Year!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question