res*_*ion 8 silverlight wpf canvas wpf-controls stretch
如何Canvas
使用可变宽度完全水平拉伸?这是父母Canvas
,所以没有父母,只有孩子.
XAML来源:它以混合http://resopollution.com/xaml.txt显示
Jam*_*add 15
使用a Grid
作为UI中的顶级元素 - 它将拉伸以填充其容器.然后在里面放一个Canvas
,它会按照你想要的方式行事.HorizontalAlignment="Stretch"
Grid
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas Background="Blue"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)
这对我有用.关键是您的顶级UI元素.虽然Grid
默认情况下填充所有可用空间,但Canvas
es只占用内容需求的空间.