开发者

How to use dockpanel to stretch a canvas?

开发者 https://www.devze.com 2023-02-17 02:10 出处:网络
<DockPanel Name=\"dcPa开发者_如何转开发nel\"> <Button Name=\"TopRect\" DockPanel.Dock=\"Top\" Background=\"LightGreen\"
<DockPanel Name="dcPa开发者_如何转开发nel">
    <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!


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.


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消