2017-10-13 45 views
0

我正在將一些Win RT代碼移植到UWP。無法按預期工作的頁面之一是HubPage。集線器頁面標題模板無法正常工作

我在HubSectionHeaderTemplate中有一個按鈕,應該替換「查看更多」HyperLink。我的模板中出現按鈕,但不接受點擊。

該文檔聲明我應該能夠用我自己的模板替換「see more」超鏈接,我相信這是我的代碼正在做但不起作用。

如果我試圖更換HubSectionHeaderTemplate,我不確定IsHeaderInteractive應該是什麼值。任何幫助apprecaited

<Page 
    x:Class="Hub_Page.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="using:Hub_Page" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"> 

    <Page.Resources> 
     <Style TargetType="HubSection"> 
      <Setter Property="HeaderTemplate"> 
       <Setter.Value> 
        <DataTemplate> 
         <Button Content="This doesn't click!" 
           Background="DarkCyan" Tapped="UIElement_OnTapped"/> 
        </DataTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 
    </Page.Resources> 

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> 

     <Grid x:Name="outerGrid"> 
      <Grid x:Name="innerGrid" 
       VerticalAlignment="Top"> 
       <Hub x:Name="hub" SectionHeaderClick="Hub_OnSectionHeaderClick" > 
        <Hub.Header> 
         <!-- Back button and page title --> 
         <Grid> 
          <StackPanel Margin="13,0,20,0" Orientation="Horizontal"> 
           <Button x:Name="backButton" Margin="0,0,20,0"/> 
           <TextBlock Text="x Manage Playlists" Margin="0,0,10,5" HorizontalAlignment="Left"/> 
           <Button Content="This does click" 
             Background="DarkGray" Tapped="UIElement_OnTapped"/> 
          </StackPanel> 
         </Grid> 
        </Hub.Header> 

        <!-- Playlists section --> 
        <HubSection Header="x Playlists" IsHeaderInteractive="True" > 
         <DataTemplate> 
          <ListView x:Name="playlistListView" 
            HorizontalAlignment="Stretch" 
            VerticalAlignment="Top" 
            SelectionMode="Single"> 
           <ListView.ItemContainerStyle> 
            <Style TargetType="ListViewItem"> 
             <Setter Property="HorizontalContentAlignment" Value="Stretch" /> 
            </Style> 
           </ListView.ItemContainerStyle> 
           <ListView.ItemTemplate> 
            <DataTemplate> 
             <!-- A playlist --> 
             <Grid HorizontalAlignment="Stretch"> 
              <StackPanel Margin="10" Orientation="Vertical" HorizontalAlignment="Stretch" MaxWidth="500"> 
               <TextBlock Text="{Binding Name}" TextTrimming="WordEllipsis" /> 
              </StackPanel> 
             </Grid> 
            </DataTemplate> 
           </ListView.ItemTemplate> 
          </ListView> 
         </DataTemplate> 
        </HubSection> 
       </Hub> 
      </Grid> 
     </Grid> 
    </Grid> 
</Page> 

回答

0

這是通過設計。你可以自己製作你自己的HubSection的按鈕。例如如下所示:

<HubSection> 
    <DataTemplate> 
      <StackPanel> 
       <Button Content="Header" Click="Button_Click" Margin="0 0 0 10"></Button> 
       <TextBlock Text="here is content."></TextBlock> 
      </StackPanel> 
    </DataTemplate> 
</HubSection>