0
使用Silverlight導航項目模板時,我希望我的頁面的內容在導航框架中水平居中,並且不會填充整個空間。如何確定導航頁面的大小
例如,考慮將這片XAML放置在Home.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像素的內容。
現在,如果我添加到此LayoutRoot Width="400" Height="100"
然後我得到的東西看起來很接近,但這些數字是固定的,將不適合,因爲內容更改大小。
如何更改Home視圖或MainPage框架的XAML以實現所需的佈局?
+1。我非常喜歡「如果它們可以比父框架更大,則需要在導航框架周圍添加滾動查看器」部分。謝謝你的提示。 – 2013-04-22 02:58:05