2017-12-20 6 views
1

텍스트 블록이있는 Hubsection과 HeaderTemplate에 단추가 있습니다. 그것은 윈도우 8에서 괜찮 작동하지만 UWP로 애플 리케이션을 마이 그 레이션하고 지금은 버튼을 클릭 할 수 없습니다. HubSection에서 작동하는 단추를 얻을 수 없습니다. HeaderTemplate

<HubSection 
Width="480" 
HorizontalAlignment="Stretch" 
Header="_XX" 
IsHeaderInteractive="True"> 
<HubSection.HeaderTemplate> 
    <DataTemplate> 
     <Grid Width="392" Margin="0,-10,0,-10"> 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition /> 
       <ColumnDefinition /> 
      </Grid.ColumnDefinitions> 

      <TextBlock 
       HorizontalAlignment="Left" 
       VerticalAlignment="Top" 
       FontSize="28" 
       Text="{Binding}" /> 
      <AppBarButton 
       Grid.Column="1" 
       HorizontalAlignment="Right" 
       VerticalAlignment="Top" 
       Command="{Binding ElementName=HubSection, Path=DataContext.MyCommand}"> 
       <AppBarButton.Icon> 
        <FontIcon 
         FontFamily="{StaticResource IconsFontFamily}" 
         FontSize="26" 
         Glyph="&#xE602;" /> 
       </AppBarButton.Icon> 
      </AppBarButton> 
     </Grid> 
    </DataTemplate> 
</HubSection.HeaderTemplate> 
<DataTemplate> 
    ... 
</DataTemplate> 

도움말

사전에 감사를 이해할 수있을 것이다.

+0

가 어디 AppBarButton의 클릭 이벤트 :이 문제를 해결하기 위해

하나 개의 솔루션은 Hub 템플릿을 복제하고 ContentControl a로 헤더를 호스트하는 데 사용되는 Button 제어를 대체하는 것입니다? –

+0

글쎄, 클릭 이벤트가 아니라 명령 속성이 설정되어 있습니다. –

답변

1

헤더가 정의 된 방식에서 문제가 발생합니다. 헤더는 이미 버튼이며 템플릿을 사용하여 버튼 내에 버튼을 추가합니다.

<Page.Resources> 
    <Style TargetType="HubSection"> 
     <Setter Property="HorizontalAlignment" Value="Stretch" /> 
     <Setter Property="VerticalAlignment" Value="Stretch" /> 
     <Setter Property="HorizontalContentAlignment" Value="Left" /> 
     <Setter Property="VerticalContentAlignment" Value="Top" /> 
     <Setter Property="Padding" Value="12,10,12,0" /> 
     <Setter Property="IsTabStop" Value="False" /> 
     <Setter Property="UseSystemFocusVisuals" Value="True" /> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="HubSection"> 
        <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> 
         <Border.Resources> 
          <ControlTemplate x:Key="HeaderButtonTemplate" TargetType="Button"> 
           <Grid x:Name="ButtonRoot" Background="Transparent"> 
            <VisualStateManager.VisualStateGroups> 
             <VisualStateGroup x:Name="CommonStates"> 
              <VisualState x:Name="Normal"> 
               <Storyboard> 
                <PointerUpThemeAnimation Storyboard.TargetName="ButtonRoot" /> 
               </Storyboard> 
              </VisualState> 
              <VisualState x:Name="PointerOver"> 
               <Storyboard> 
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground"> 
                 <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource HubSectionHeaderButtonForegroundPointerOver}" /> 
                </ObjectAnimationUsingKeyFrames> 
                <PointerUpThemeAnimation Storyboard.TargetName="ButtonRoot" /> 
               </Storyboard> 
              </VisualState> 
              <VisualState x:Name="Pressed"> 
               <Storyboard> 
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground"> 
                 <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource HubSectionHeaderButtonForegroundPressed}" /> 
                </ObjectAnimationUsingKeyFrames> 
                <PointerDownThemeAnimation Storyboard.TargetName="ButtonRoot" /> 
               </Storyboard> 
              </VisualState> 
              <VisualState x:Name="Disabled"> 
               <Storyboard> 
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground"> 
                 <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource HubSectionHeaderButtonForegroundDisabled}" /> 
                </ObjectAnimationUsingKeyFrames> 
               </Storyboard> 
              </VisualState> 
              <VisualState x:Name="ImitatedTextBlock"> 
               <Storyboard> 
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground"> 
                 <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource HubSectionHeaderForeground}" /> 
                </ObjectAnimationUsingKeyFrames> 
               </Storyboard> 
              </VisualState> 
             </VisualStateGroup> 
            </VisualStateManager.VisualStateGroups> 
            <ContentPresenter x:Name="ContentPresenter" 
            Content="{TemplateBinding Content}" 
            ContentTemplate="{TemplateBinding ContentTemplate}" 
            VerticalAlignment="Center" 
            OpticalMarginAlignment="TrimSideBearings" /> 
           </Grid> 
          </ControlTemplate> 
         </Border.Resources> 
         <Grid Margin="{TemplateBinding Padding}" HorizontalAlignment="Stretch" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"> 
          <Grid.RowDefinitions> 
           <RowDefinition Height="Auto" /> 
           <RowDefinition Height="Auto" /> 
           <RowDefinition Height="*" /> 
          </Grid.RowDefinitions> 
          <Rectangle x:Name="HubHeaderPlaceholder" Grid.Row="0" /> 
          <Grid Grid.Row="1"> 
           <Grid.ColumnDefinitions> 
            <ColumnDefinition Width="*" /> 
            <ColumnDefinition Width="Auto" /> 
           </Grid.ColumnDefinitions> 
           <!-- The change is here --> 
           <ContentControl x:Name="HeaderButton" 
           Grid.Row="1" 
           Grid.Column="0" 
           UseSystemFocusVisuals="True" 
           Content="{TemplateBinding Header}" 
           ContentTemplate="{TemplateBinding HeaderTemplate}" 
           Foreground="{ThemeResource HubSectionHeaderButtonForeground}" 
           Margin="{ThemeResource HubSectionHeaderThemeMargin}" 
           FontSize="{ThemeResource HubSectionHeaderThemeFontSize}" 
           FontWeight="{ThemeResource HubSectionHeaderThemeFontWeight}" 
           HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
           VerticalAlignment="Bottom" 
           IsTabStop="False" /> 
           <Button x:Name="SeeMoreButton" 
           Grid.Row="1" 
           Grid.Column="1" 
           UseSystemFocusVisuals="True" 
           Visibility="Collapsed" 
           HorizontalAlignment="Right" 
           VerticalAlignment="Bottom" 
           Foreground="{ThemeResource HubSectionHeaderButtonForeground}" 
           Margin="{ThemeResource HubSectionHeaderSeeMoreThemeMargin}" 
           Template="{StaticResource HeaderButtonTemplate}" 
           FontSize="{ThemeResource HubSectionHeaderSeeMoreThemeFontSize}" 
           FontWeight="{ThemeResource HubSectionHeaderThemeFontWeight}" /> 
          </Grid> 
          <ContentPresenter x:Name="ContentPresenter" 
          ContentTemplate="{TemplateBinding ContentTemplate}" 
          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
          Grid.Row="2" /> 
         </Grid> 
        </Border> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
</Page.Resources> 
+0

그리고 이것은 정확히 내가 한 일이다. 정말 고마워! –

관련 문제