Silverlight:如何让这个控件占用所有可用空间?

时间:2010-11-23 19:54:31

标签: silverlight xaml

我正在构建一个SL 4应用程序。用户界面由三个主要部分组成:顶部搜索栏,底部收藏栏以及两者之间的页面内容。我希望页面内容占用所有可用空间。现在,它水平扩展但不垂直扩展。我不确定我做错了什么。这是XAML:

<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>

我可能做错了什么?

2 个答案:

答案 0 :(得分:4)

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

答案 1 :(得分:1)

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

你是否将此Grid放入其他内容(如StackPanel)中,以防止它填满所有垂直空间?

相关问题