2017-08-24 65 views
1

有沒有人有一個想法,爲什麼焦點樞軸項目上的藍色下劃線不可見? XAML中(與.NET 2.0芯新創建的空UWP的應用程序,VS 2017 15.3.2)是簡單的這樣的:UWP樞軸:沒有關於焦點樞軸項目的藍色下劃線

<Pivot> 
    <PivotItem Header="Testt 1">Test 1</PivotItem> 
    <PivotItem Header="Testt 2">Test 2</PivotItem> 
    <PivotItem Header="Testt 3">Test 3</PivotItem> 
</Pivot> 

和MS是說,「默認情況下,鍵盤焦點在樞軸頭是用下劃線表示。「 (https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/tabs-pivot

啓動後很少幾次,它在第一個數據項上出現,但在點擊另一個數據後卻消失了。

+1

「啓動後很少幾次,它在第一個數據項上出現,但在點擊另一個數據後卻消失了。」如果你在它們之間選擇而不是點擊呢?畢竟它確實說了鍵盤焦點。如果在創業之後還沒有做任何事情,我也會感到驚訝。 – BoltClock

+0

啊,你是對的,那麼它就會出現!我怎樣才能讓它顯示點擊/竊聽? – IngoB

回答

1

PivotHeaderItem的風格中,有一個Rectangle,稱爲FocusPipe,它是您在鍵盤導航期間看到的焦點視覺效果。默認情況下,只有當它處於Focused狀態時纔可見。

如果要使其可見,只需在SelectedSelectedPressedSelectedPointerOver狀態設置其VisibilityVisible

<Application.Resources> 
    <Style TargetType="PivotHeaderItem"> 
     <Setter Property="FontSize" 
       Value="{ThemeResource PivotHeaderItemFontSize}" /> 
     <Setter Property="FontFamily" 
       Value="{ThemeResource PivotHeaderItemFontFamily}" /> 
     <Setter Property="FontWeight" 
       Value="{ThemeResource PivotHeaderItemThemeFontWeight}" /> 
     <Setter Property="CharacterSpacing" 
       Value="{ThemeResource PivotHeaderItemCharacterSpacing}" /> 
     <Setter Property="Background" 
       Value="{ThemeResource PivotHeaderItemBackgroundUnselected}" /> 
     <Setter Property="Foreground" 
       Value="{ThemeResource PivotHeaderItemForegroundUnselected}" /> 
     <Setter Property="Padding" 
       Value="{ThemeResource PivotHeaderItemMargin}" /> 
     <Setter Property="Height" 
       Value="48" /> 
     <Setter Property="VerticalContentAlignment" 
       Value="Center" /> 
     <Setter Property="IsTabStop" 
       Value="False" /> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="PivotHeaderItem"> 
        <Grid x:Name="Grid" 
          Background="{TemplateBinding Background}" 
          Padding="{TemplateBinding Padding}"> 
         <VisualStateManager.VisualStateGroups> 
          <VisualStateGroup x:Name="SelectionStates"> 
           <VisualStateGroup.Transitions> 
            <VisualTransition From="Unselected" 
                 To="UnselectedLocked" 
                 GeneratedDuration="0:0:0.33" /> 
            <VisualTransition From="UnselectedLocked" 
                 To="Unselected" 
                 GeneratedDuration="0:0:0.33" /> 
           </VisualStateGroup.Transitions> 
           <VisualState x:Name="Disabled"> 
            <Storyboard> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" 
                     Storyboard.TargetProperty="Foreground"> 
              <DiscreteObjectKeyFrame KeyTime="0" 
                    Value="{ThemeResource PivotHeaderItemForegroundDisabled}" /> 
             </ObjectAnimationUsingKeyFrames> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Grid" 
                     Storyboard.TargetProperty="Background"> 
              <DiscreteObjectKeyFrame KeyTime="0" 
                    Value="{ThemeResource PivotHeaderItemBackgroundDisabled}" /> 
             </ObjectAnimationUsingKeyFrames> 
            </Storyboard> 
           </VisualState> 
           <VisualState x:Name="Unselected" /> 
           <VisualState x:Name="UnselectedLocked"> 
            <Storyboard> 
             <DoubleAnimation Storyboard.TargetName="ContentPresenterTranslateTransform" 
                 Storyboard.TargetProperty="X" 
                 Duration="0" 
                 To="{ThemeResource PivotHeaderItemLockedTranslation}" /> 
             <DoubleAnimation Storyboard.TargetName="ContentPresenter" 
                 Storyboard.TargetProperty="(UIElement.Opacity)" 
                 Duration="0" 
                 To="0" /> 
            </Storyboard> 
           </VisualState> 
           <VisualState x:Name="Selected"> 
            <VisualState.Setters> 
             <Setter Target="FocusPipe.Visibility" 
               Value="Visible" /> 
            </VisualState.Setters> 
            <Storyboard> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" 
                     Storyboard.TargetProperty="Foreground"> 
              <DiscreteObjectKeyFrame KeyTime="0" 
                    Value="{ThemeResource PivotHeaderItemForegroundSelected}" /> 
             </ObjectAnimationUsingKeyFrames> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Grid" 
                     Storyboard.TargetProperty="Background"> 
              <DiscreteObjectKeyFrame KeyTime="0" 
                    Value="{ThemeResource PivotHeaderItemBackgroundSelected}" /> 
             </ObjectAnimationUsingKeyFrames> 
            </Storyboard> 
           </VisualState> 
           <VisualState x:Name="UnselectedPointerOver"> 
            <Storyboard> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" 
                     Storyboard.TargetProperty="Foreground"> 
              <DiscreteObjectKeyFrame KeyTime="0" 
                    Value="{ThemeResource PivotHeaderItemForegroundUnselectedPointerOver}" /> 
             </ObjectAnimationUsingKeyFrames> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Grid" 
                     Storyboard.TargetProperty="Background"> 
              <DiscreteObjectKeyFrame KeyTime="0" 
                    Value="{ThemeResource PivotHeaderItemBackgroundUnselectedPointerOver}" /> 
             </ObjectAnimationUsingKeyFrames> 
            </Storyboard> 
           </VisualState> 
           <VisualState x:Name="SelectedPointerOver"> 
            <VisualState.Setters> 
             <Setter Target="FocusPipe.Visibility" 
               Value="Visible" /> 
            </VisualState.Setters> 
            <Storyboard> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" 
                     Storyboard.TargetProperty="Foreground"> 
              <DiscreteObjectKeyFrame KeyTime="0" 
                    Value="{ThemeResource PivotHeaderItemForegroundSelectedPointerOver}" /> 
             </ObjectAnimationUsingKeyFrames> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Grid" 
                     Storyboard.TargetProperty="Background"> 
              <DiscreteObjectKeyFrame KeyTime="0" 
                    Value="{ThemeResource PivotHeaderItemBackgroundSelectedPointerOver}" /> 
             </ObjectAnimationUsingKeyFrames> 
            </Storyboard> 
           </VisualState> 
           <VisualState x:Name="UnselectedPressed"> 
            <Storyboard> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" 
                     Storyboard.TargetProperty="Foreground"> 
              <DiscreteObjectKeyFrame KeyTime="0" 
                    Value="{ThemeResource PivotHeaderItemForegroundUnselectedPressed}" /> 
             </ObjectAnimationUsingKeyFrames> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Grid" 
                     Storyboard.TargetProperty="Background"> 
              <DiscreteObjectKeyFrame KeyTime="0" 
                    Value="{ThemeResource PivotHeaderItemBackgroundUnselectedPressed}" /> 
             </ObjectAnimationUsingKeyFrames> 
            </Storyboard> 
           </VisualState> 
           <VisualState x:Name="SelectedPressed"> 
            <VisualState.Setters> 
             <Setter Target="FocusPipe.Visibility" 
               Value="Visible" /> 
            </VisualState.Setters> 
            <Storyboard> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" 
                     Storyboard.TargetProperty="Foreground"> 
              <DiscreteObjectKeyFrame KeyTime="0" 
                    Value="{ThemeResource PivotHeaderItemForegroundSelectedPressed}" /> 
             </ObjectAnimationUsingKeyFrames> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Grid" 
                     Storyboard.TargetProperty="Background"> 
              <DiscreteObjectKeyFrame KeyTime="0" 
                    Value="{ThemeResource PivotHeaderItemBackgroundSelectedPressed}" /> 
             </ObjectAnimationUsingKeyFrames> 
            </Storyboard> 
           </VisualState> 
          </VisualStateGroup> 
          <VisualStateGroup x:Name="FocusStates"> 
           <VisualState x:Name="Focused"> 
            <VisualState.Setters> 
             <Setter Target="FocusPipe.Visibility" 
               Value="Visible" /> 
            </VisualState.Setters> 
           </VisualState> 
           <VisualState x:Name="Unfocused" /> 
          </VisualStateGroup> 
         </VisualStateManager.VisualStateGroups> 
         <Grid.RenderTransform> 
          <TranslateTransform x:Name="ContentPresenterTranslateTransform" /> 
         </Grid.RenderTransform> 
         <ContentPresenter x:Name="ContentPresenter" 
              Content="{TemplateBinding Content}" 
              ContentTemplate="{TemplateBinding ContentTemplate}" 
              FontSize="{TemplateBinding FontSize}" 
              FontFamily="{TemplateBinding FontFamily}" 
              FontWeight="{TemplateBinding FontWeight}" 
              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
              OpticalMarginAlignment="TrimSideBearings" /> 
         <Rectangle x:Name="FocusPipe" 
            Fill="{ThemeResource PivotHeaderItemFocusPipeFill}" 
            Height="2" 
            VerticalAlignment="Bottom" 
            HorizontalAlignment="Stretch" 
            Visibility="Collapsed" /> 
        </Grid> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
</Application.Resources> 
+1

太棒了,它的作品!非常感謝。 :) – IngoB