如果您不想創建一個應用程序,用戶可以在頁面之間進行導航(並使用後退按鈕返回),則可以基於單個頁面創建應用程序。如果您創建了一個Windows Phone應用程序項目,以下是Visual Studio爲您創建的某種程度的修改版本。
<phone:PhoneApplicationPage
x:Class="PhoneApp1.MainPage"
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"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="728"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}">
<Grid Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Margin="12,17,0,28">
<TextBlock
Text="MY APPLICATION"
Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock
Text="page name"
Margin="9,-7,0,0"
Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<Grid Grid.Row="1" Margin="12,0,12,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<!-- The three buttons -->
<StackPanel Orientation="Horizontal">
<Button Content="Button 1"/>
<Button Content="Button 2"/>
<Button Content="Button 3"/>
</StackPanel>
<!-- The main content -->
<TextBlock Grid.Row="1"
Text="Content always changing"
Style="{StaticResource PhoneTextTitle1Style}"
TextWrapping="Wrap"
TextAlignment="Center"/>
</Grid>
</Grid>
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton
IconUri="/Images/appbar_button1.png"
Text="Button 1"/>
<shell:ApplicationBarIconButton
IconUri="/Images/appbar_button2.png"
Text="Button 2"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>
這裏是它的外觀在設計師

在這種情況下,主要內容(即總是在變化)是一個<TextBlock>
,但你可以使用其他組成的板控件或UserControl
。如果將多個面板/控件放在同一個網格單元中,則可以通過隱藏除一個面板/控件以外的所有其他面板來完全更改佈局。
對於第一排按鈕,我使用了水平的<StackPanel>
,但您可能想要使用其他方法來更好地控制佈局和對齊。
對於最下面一排按鈕,您應該使用屬於標準Windows Phone 7用戶體驗的應用程序欄。
您可以使用應用程序欄爲您的應用程序的按鈕,下面展示瞭如何使用不同的應用程序欄的樞軸控件的不同頁面,但是相同的技術可以被用於非透視基於網頁:HTTP:// msdn.microsoft.com/en-us/library/hh394036(v=vs.92).aspx –