2009-06-11 33 views

回答

47

您可以使用视框在视觉上放大的东西,以适应在其容器内。其他解决方案在这里工作,但他们只是扩展控制,而不是其内容。 ViewBox将拉伸两个。

<!-- Big grid, will stretch its children to fill itself --> 
<Grid Width="1000" Height="1000"> 
<!-- The button is stretched, but its text remains teeny tiny --> 
<Button> 
    <!-- The viewbox will stretch its content 
    to fit the final size of the button --> 
    <Viewbox 
     Margin="4" 
     VerticalAlignment="Stretch" 
     Height="Auto"> 
     <!-- The textblock and its contents are 
     stretched to fill its parent --> 
     <TextBlock 
      Text="Bartenders" /> 
    </Viewbox> 
</Button> 
</Grid> 
+1

谢谢,威尔,我认为它*必须*是可能的,但我有不得不绑定字体大小属性的愿景。 – Mark 2009-06-12 07:31:13

0

使用DockPanel中的父容器

<DockPanel> 
    <TextBlock /> 
</DockPanel> 
1

设置Horizo​​nalAlignment/VerticalAlignment为 “拉伸”。

2

依赖于父容器

电网,DockPanel中会伸展你的控制 的StackPanel,WrapPanel会留待控制大小本身..