2010-11-23 62 views
1

我正在构建一个SL 4应用程序。用户界面由三个主要部分组成:顶部搜索栏,底部最喜欢栏以及两者之间的页面内容。我希望页面内容占用所有可用空间。现在,它横向扩展,但不是垂直扩展。我不确定我做错了什么。这里是XAML:Silverlight:如何让此控件占用所有可用空间?

<Grid x:Name="LayoutRoot" Background="BurlyWood"> 
    <Grid.RowDefinitions> 
     <RowDefinition /> 
     <RowDefinition /> 
     <RowDefinition /> 
    </Grid.RowDefinitions> 

    <my:TopSearchBar x:Name="topSearchBar" Grid.Row="0" Navigator="{Binding ElementName=navigationFrame}" HorizontalAlignment="Stretch" VerticalAlignment="Top" /> 

    <!-- I want this to take up all available space between the bottom and top elements --> 
    <navigation:Frame x:Name="navigationFrame" Source="/HomePage.xaml" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="BlueViolet" /> 

    <my:BottomFavoritesBar x:Name="bottomFavoritesBar" Grid.Row="2" Navigator="{Binding ElementName=navigationFrame}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" /> 

</Grid> 

我能做什么错?

回答

4
<Grid.RowDefinitions> 
    <RowDefinition Height="Auto" /> 
    <RowDefinition Height="*" /> 
    <RowDefinition Height="Auto"/> 
</Grid.RowDefinitions> 
+0

是不是`Height =“Auto”隐式? – 2010-11-23 20:16:04

+0

自动是隐含的,但重要的部分是“*”列。这告诉它占用所有可用空间。如果没有这3列将是自动的,这意味着内容所需的最低限度。 – Stephan 2010-11-23 20:31:40

1

我无法重现您的问题。对我而言,网格确实垂直扩展以填充其空间,并且其每个子控件占用三分之一的高度。

你有没有这个Grid里面的东西,像一个StackPanel,它会阻止它填满所有的垂直空间?