宽度问题 [英] Width question
本文介绍了宽度问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下控件的宽度为1000.所包含的控件均未指定宽度。他们不应该伸展来填充他们的容器吗?对于每个控件,Blend表示Width = Auto,HorizontialAlignment = Stretch。很抱歉提出愚蠢的问题我是一个火红的初学者。
谢谢!
The width of the control below is 1000. None of the contained controls specifies a width. Shouldn't they stretch to fill their container? For each control, Blend says Width=Auto, HorizontialAlignment=Stretch. Sorry for asking dumb questions I'm a flaming beginner.
Thanks!
<yada yada Width="1000">
<Grid x:Name="LayoutRoot" Background="White">
<controls:TreeView x:Name="TreeView1" ItemsSource="{Binding}" BorderThickness="6,1,1,1">
<controls:TreeView.ItemTemplate>
<common:HierarchicalDataTemplate ItemsSource="{Binding Replies}">
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Date, Mode=OneWay}" Margin="10,10,0,0" Height="10" />
<Rectangle Stroke="Black" Fill="#FFD2C7C7" Height="25"/>
<TextBlock Text="{Binding Comment}" />
<TextBox x:Name="ReplyText" />
<Button Content="Reply" Click="ReplyButton_Click" />
</StackPanel>
</common:HierarchicalDataTemplate>
</controls:TreeView.ItemTemplate>
</controls:TreeView>
</Grid>
</UserControl>
推荐答案
您好Sam,您可以设置宽度和要拉伸的高度(属性>布局面板的对齐部分右侧的第4个图标)以及自动的宽度和高度。这将自动将子控件拉伸到其父容器的大小。
Hi Sam, you can set the width and height to stretch ( the 4th icon on the right on the alignment section of the Properties>Layout panel) and the width and height to auto. This will automatically stretch the child controls to the size of their parent container.
这篇关于宽度问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文