我正在試用WIndows 8上的tutorial。我需要添加Navigation Bar
。步驟如下:在Windows 8中添加頂部導航欄 - 教程問題
以下是本教程。
- 在解決方案資源管理器中,雙擊MainPage.xaml將其打開。
- 在文檔大綱中,選擇「pageRoot」元素。
- 在「屬性」面板中,單擊「屬性」按鈕()以顯示「屬性」視圖。
- 在「屬性」面板的「常用」下,找到TopAppBar屬性。
- 單擊TopAppBar旁邊的New按鈕。一個AppBar控件被添加到頁面中。
- 在文檔大綱中,展開TopAppBar屬性。
- 選擇「photoPageButton」元素,將其拖到AppBar上並放下。
- 在「屬性」面板的「佈局」下,將HorizontalAlignment屬性設置爲Right()。
- 按F5構建並運行應用程序。要測試應用欄,請右鍵單擊主頁面。應用欄在屏幕頂部打開。
我雙擊在MainPage.xaml
,然後在Document Outline
我選擇pageRoot
。並在properties
窗口展開Common
和我點擊New
旁邊TopAppBar
。
它在其下面添加了其他幾個Fields
。 Allow Drop
,Background
和Cache Mode
就是其中的一部分。然後在Document Outline
我把按鈕拖到下TopAddBar
。將HorizontalAlignment
更改爲Right
,構建並執行應用程序。但是我沒有看到添加到頂部導航欄的按鈕。我在這裏做錯了什麼?
UPDATE
<Page.Resources>
<!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
<x:String x:Key="AppName">My Application</x:String>
</Page.Resources>
<common:LayoutAwarePage.TopAppBar>
<AppBar Background="#E5A41D1D" AllowDrop="True" BorderBrush="#E5C5A7A7" HorizontalAlignment="Right">
<Button Content="Next Page
" HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="230" Height="70" Background="#FF12668D" FontFamily="Shruti" FontSize="36" Click="Button_Click_2"/>
</AppBar>
</common:LayoutAwarePage.TopAppBar>
<!--
This grid acts as a root panel for the page that defines two rows:
* Row 0 contains the back button and page title
* Row 1 contains the rest of the page layout
-->
<Grid Style="{StaticResource LayoutRootStyle}" Background="#FF282D40">
<Grid.RowDefinitions>
<RowDefinition Height="140"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Back button and page title -->
<!-- Back button and page title -->
<!-- Back button and page title -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
<TextBlock x:Name="pageTitle" Grid.Column="1" Text="Welcome !!! " Style="{StaticResource PageHeaderTextStyle}" Foreground="#DE2374AC"/>
</Grid>
<VisualStateManager.VisualStateGroups>
<!-- Visual states reflect the application's view state -->
<VisualStateGroup x:Name="ApplicationViewStates">
<VisualState x:Name="FullScreenLandscape"/>
<VisualState x:Name="Filled"/>
<!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
<VisualState x:Name="FullScreenPortrait">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<!-- The back button and title have different styles when snapped -->
<VisualState x:Name="Snapped">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
你可以發佈生成的xaml嗎? – mydogisbox
我用xaml更新了我的帖子。 –
當鼠標右鍵單擊或點擊Windows-Z調出應用程序欄時,您會看到什麼?它在那裏,但是是空的,還是根本沒有出現? FWIW,您的標記適合我。 –