Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xaml UWP轴:焦点轴项目上没有蓝色下划线_Xaml_Uwp_Uwp Xaml - Fatal编程技术网

Xaml UWP轴:焦点轴项目上没有蓝色下划线

Xaml UWP轴:焦点轴项目上没有蓝色下划线,xaml,uwp,uwp-xaml,Xaml,Uwp,Uwp Xaml,有人知道为什么焦点项目上的蓝色下划线不可见吗?xaml(在新创建的带有.NET core 2.0的空UWP应用程序中,VS 2017 15.3.2)非常简单,如下所示: <Pivot> <PivotItem Header="Testt 1">Test 1</PivotItem> <PivotItem Header="Testt 2">Test 2</PivotItem> <PivotItem Header=

有人知道为什么焦点项目上的蓝色下划线不可见吗?xaml(在新创建的带有.NET core 2.0的空UWP应用程序中,VS 2017 15.3.2)非常简单,如下所示:

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

测试1
测试2
测试3
MS说“默认情况下,键盘焦点在轴标题上用下划线表示。”()


启动后很少有一次,它出现在第一个透视项上,但在单击另一个透视项后消失。

PivotHeaderItem
的样式中,有一个名为
FocusPipe
矩形,它是您在键盘导航期间看到的焦点视觉。默认情况下,它仅在处于
聚焦状态时可见

如果要使其可见,只需在
Selected
中将其
可见性设置为
visible
SelectedPressed
selectedpointer over
状态

<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>

一个更简单的答案是:

<SolidColorBrush x:Key="PivotHeaderItemSelectedPipeFill" Color="Yellow"/>


对于黄色下划线。

“启动后很少有一次,它出现在第一个轴心项目上,但在单击另一个轴心项目后消失。”如果您在它们之间进行制表而不是单击,该怎么办?毕竟它说的是键盘焦点。我也会感到惊讶,如果它是在启动后,你还没有做任何事情。啊,你是对的,然后它出现了!如何使其在单击/点击时显示?我没有看到solidcolorbrush:x:key PivotHeaderItemSelectedPipeFill工作得很好。