Xaml 如何调整导航页面的大小

Xaml 如何调整导航页面的大小,xaml,silverlight-4.0,Xaml,Silverlight 4.0,使用Silverlight导航项目模板,我希望我的页面内容在导航框架中水平居中,而不是占据整个空间 例如,考虑这段XAML放置HOM.XMAL视图。结果是一个圆角的米色背景,在中间适当地用“一些有趣的内容”填充整个框架 <navigation:Page x:Class="SilverlightApplication3.Home" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns

使用Silverlight导航项目模板,我希望我的页面内容在导航框架中水平居中,而不是占据整个空间

例如,考虑这段XAML放置HOM.XMAL视图。结果是一个圆角的米色背景,在中间适当地用“一些有趣的内容”填充整个框架

<navigation:Page x:Class="SilverlightApplication3.Home" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
    Title="Home"
    Style="{StaticResource PageStyle}">
    <Grid x:Name="LayoutRoot">
        <Border BorderThickness="5" CornerRadius="20" Background="Beige" Width="Auto" Height="Auto">
            <TextBlock Text="Some interesting content goes here" FontSize="20" 
                       FontFamily="Comic Sans MS" Foreground="Teal" 
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center" Margin="20"/>
        </Border>
    </Grid>
</navigation:Page>

我所希望的是,文本将被内容周围20像素的米色背景包围

现在,如果我将this LayoutRoot
Width=“400”Height=“100”
添加到这个布局中,那么我会得到一些看起来很接近的东西,但是这些数字是固定的,随着内容大小的变化,它们将不适合


如何更改主视图或主页框架的XAML以实现所需的布局?

在MainPage.XAML中,可以将导航框架设置为内容居中(默认为拉伸)

e、 g


这将显示中间的任何内容页,不管它们是什么大小。最好为子页面添加最小和最大大小限制,以避免折叠过小,但这是一个设计问题。如果它们可能比父框架大,则需要在导航框架周围添加滚动查看器。

+1。我真的很喜欢“如果它们可以比父框架大,你需要在导航框架周围添加一个滚动查看器”部分。谢谢你的提示。
 <navigation:Frame x:Name="ContentFrame" Style="{StaticResource ContentFrameStyle}" 
                              Source="/Home" Navigated="ContentFrame_Navigated" NavigationFailed="ContentFrame_NavigationFailed"
                              HorizontalContentAlignment="Center"
                              VerticalContentAlignment="Center">