开发者

How to use dockpanel to stretch a canvas?

<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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜