我对这件事失去了耐心。我正在开发一个WindowsPhone7应用程序,我不知道使用什么布局管理器来实现以下目标:
基本上,当我使用一个网格作为布局根时,我无法使网格扩展到电话应用程序页面的大小。当主内容区已满时,一切正常,按钮位于我希望它位于的位置。但是,如果页面内容很短,则网格的宽度只能容纳其内容,然后按钮(我非常希望保持在屏幕右边缘附近)从右边缘移动。
如果我替换网格并对布局根使用垂直方向的堆栈面板,则按钮将位于我所需的位置,但内容区域将能够超出底边。所以,当我在主内容区域中放置一个装满项目的列表框时,它不会将其高度调整为完全在视图中,但是该列表框中的大多数项目只是在显示区域的底部边缘下呈现。
HorizontalAlignment="Right"
但结果与网格相同,当内容区域中没有足够的内容(或标题较短)时,网格的大小也会缩小。
那我该怎么做呢?
==编辑==
<phone:PhoneApplicationPage
x:Name="categoriesPage"
x:Class="CatalogueBrowser.CategoriesPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
xmlns:ctrls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
shell:SystemTray.IsVisible="True">
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" >
<TextBlock Text="Browsing:"
Margin="10,10"
Style="{StaticResource PhoneTextTitle3Style}" />
<TextBlock x:Name="ListTitle"
Text="{Binding DisplayName}"
Margin="0,10"
Style="{StaticResource PhoneTextTitle3Style}" />
</StackPanel>
<Button Grid.Column="1"
x:Name="btnRefineSearch"
Content="Refine Search"
Style="{StaticResource buttonBarStyle}"
FontSize="14" />
</Grid>
<Grid x:Name="ContentPanel" Grid.Row="1">
<ListBox x:Name="CategoryList"
ItemsSource="{Binding Categories}"
Style="{StaticResource CatalogueList}"
SelectionChanged="CategoryList_SelectionChanged"/>
</Grid>
</Grid>
</phone:PhoneApplicationPage>
这就是仿真器中具有上述XAML标记的页面的外观: