0
<DockPanel Name="dcPanel"> <Button Name="TopRect" DockPanel.Dock="Top" Background="LightGreen" Height="50" Content="Top" Margin="30,50,0,0" /> </DockPanel> 

The code above stretch a button if I maximize the window. How can I add a Canvas inside the dockpanel, so when I maximize the window, all the canvas content will be stretched? thanks!

2 Answers 2

2

The DockPanel will stretch the Canvas, but the Canvas will never stretch it's children. The Canvas always uses the desired size of it's children when arranging them.

Sign up to request clarification or add additional context in comments.

Comments

1

Try setting the Width, and Height to Auto. (of a canvas you can add)

EDIT:
I used this code, and it works perfectly:

<DockPanel> <Canvas Background="Black" /> </DockPanel> 

2 Comments

dude, try adding a button -.-
As CodeNaked pointed out, it's impossible, try adding a dockpannel in the canvas, and you can see the prove that it can't be done, because a dockpanel usually consumes all space it has access too, that means that the canvas doesn't give that space. May I suggest using a <grid>?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.