使用此代码,我希望看到200x200的3个项目的窗口。带有滚动条的第二项或中间项在最大化窗口时无法伸展到其完整大小。“我忘了告诉你,当窗口处于正常状态时,我需要精确的高度大小(例如120*)的滚动查看器。如果窗口被拉伸,那么我想用它的”自动“大小来伸缩所有的项(意思是我想要显示满滚动查看器的项)。”如何解决?
<Title="Window1" Height="200" Width="200">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBox Grid.Row="0" Text="Hi" VerticalAlignment="Center"/>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBox Grid.Row="0" Text="HI" VerticalAlignment="Center"/>
<TextBox Grid.Row="1" Text="HI" VerticalAlignment="Center"/>
<TextBox Grid.Row="2" Text="HI" VerticalAlignment="Center"/>
<TextBox Grid.Row="3" Text="HI" VerticalAlignment="Center"/>
</Grid>
</ScrollViewer>
<TextBox Grid.Row="2" Text="Hello Hello Hello "/>
</Grid>请看下图:

或者访问http://i42.tinypic.com/10r7994.png查看全尺寸图片。
发布于 2013-09-05 17:14:49
尝试使用Height="*"将剩余空间用于中间项目:
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>发布于 2013-09-05 17:19:29
您应该设置ScrollViewer的MinHeight和MinWidth。使用元素绑定窗口的高度和宽度的ScrollViewer的高度和宽度。
Like-- MinHeight="120“MinWidth="120”
绑定“{Height= Path=Height,ElementName=Wind}”
绑定“{Width= Path=Width,ElementName=Wind}”
应该能行得通。
https://stackoverflow.com/questions/18632155
复制相似问题