2012-03-20 35 views
0

我正在使用C#和XAML開發具有Visual Studio 2011測試版的Metro風格應用程序。我想在我的頁面底部顯示一個AppBar。根據一些消息來源,我將不得不在<Page.BottomAppBar>...</Page.BottomAppBar>標籤內編寫AppBar控件標籤。在頁面底部顯示應用程序欄

但是,儘管這樣做,被在XAML頁面上生成一個錯誤,他說:

BottomAppBar無法識別的頁面。

請幫我這個。謝謝。

+0

這仍然是相關的任何方式?我看到它是昨天編輯的。 – 2012-10-12 13:09:39

回答

2

UPDATE: Altough的方法最初張貼在大多數情況下,作品不建議與appbar動畫出現的問題,點擊測試......相反Page.TopAppBar和Page.BottomAppBar在http://social.msdn.microsoft.com/Forums/en/winappswithcsharp/thread/1044f2fb-bc55-4391-ac82-02c5d5e75970規定應使用。

你只需要在appbar的垂直對齊方式設置爲底部:

<AppBar Grid.Row="1" HorizontalContentAlignment="Stretch" Height="88" VerticalContentAlignment="Stretch" VerticalAlignment="Bottom"> 
... 
</Appbar> 

而且確保appbar被嵌入元素在屏幕的底部。這意味着對於標準頁面(具有2行的網格),應用欄必須嵌入第二行(Grid.Row = 1)。

最後一件事是,你必須確保appbar是Z順序中最頂層的。爲此,您必須在xaml文件的末尾添加底部的appbar。這意味着,如果你有這樣的:

<GridView Grid.Row="1">...</GridView> 

你有權責令控件臨客這樣的:

<GridView Grid.Row="1">...</GridView> 
<AppBar Grid.Row="1">...</AppBar> 
+0

不錯的答案,@paiden。 – 2012-10-11 07:48:43

2

這是BottomAppBar的例子:

<Page.BottomAppBar> 
    <AppBar x:Name="MyappBar" Padding="10,0,10,0" 
      BorderThickness="0" 
      Opened="AppBar_Opened" Closed="AppBar_Closed" > 
     <Grid> 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="50*"/> 
       <ColumnDefinition Width="50*"/> 
      </Grid.ColumnDefinitions> 
      <StackPanel x:Name="LeftPanel" Orientation="Horizontal" Grid.Column="0" HorizontalAlignment="Left"> 
       <Button x:Name="btnEdit" Style="{StaticResource EditAppBarButtonStyle}"/> 
       <Button x:Name="btnSave" Style="{StaticResource SaveAppBarButtonStyle}"/> 
      </StackPanel> 
      <StackPanel x:Name="RightPanel" Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right"> 
       <Button x:Name="btnPhoto" Style="{StaticResource PhotoAppBarButtonStyle}" Click="CapturePhoto_Click" /> 
       <Button x:Name="btnHelp" Style="{StaticResource HelpAppBarButtonStyle}"/> 
      </StackPanel> 
     </Grid> 
    </AppBar> 
</Page.BottomAppBar> 

試圖把它後</Page.Resources>在您的xaml文件中。 記得取消註釋中的按鈕樣式StandardStyles.xaml常見文件夾。

相關問題