Xaml 枢轴控制中的uwp xbox应用程序XYNavigation

Xaml 枢轴控制中的uwp xbox应用程序XYNavigation,xaml,uwp,xbox,gamepad,xbox-one,Xaml,Uwp,Xbox,Gamepad,Xbox One,我是一名经验丰富的uwp开发者,但却是uwp xbox平台的初学者。我正在尝试为我的应用程序设置XY导航,并尝试使用键盘进行测试(因为我自己没有xbox) 我使用的是Pivot视图,我可以使用左右箭头键轻松地在Pivot项目之间导航,这很有意义。但是,当使用透视选项选择“我的设置”页面时(设置透视标题处于焦点位置,并且“设置透视”项目处于视图中),我尝试将我的焦点垂直向下移动到“设置”页面中的第一个控件(单选按钮),但我无法做到这一点,焦点将保留在“设置”标题上,并且不会在页面上向下移动 因此,

我是一名经验丰富的uwp开发者,但却是uwp xbox平台的初学者。我正在尝试为我的应用程序设置XY导航,并尝试使用键盘进行测试(因为我自己没有xbox)

我使用的是Pivot视图,我可以使用左右箭头键轻松地在Pivot项目之间导航,这很有意义。但是,当使用透视选项选择“我的设置”页面时(设置透视标题处于焦点位置,并且“设置透视”项目处于视图中),我尝试将我的焦点垂直向下移动到“设置”页面中的第一个控件(单选按钮),但我无法做到这一点,焦点将保留在“设置”标题上,并且不会在页面上向下移动

因此,我如何在按下按钮时将焦点从轴标题向下移动到页面内的第一个控件,反之亦然,即:当第一个控件聚焦时,我应该向上移动以返回该页面的轴标题,因为我认为这是uwp xbox上具有轴控件的传统导航,对吗

其次,我观看的文档和xbox应用程序开发视频建议将焦点设置在一个有意义的元素上,当应用程序加载时,应该使用this.focus()方法还是有更有效的方法使用xaml

代码:

Pivot.xaml

<Grid x:Name="MainGrid">
    <Pivot x:Uid="PivotPage" x:Name="MainPivot" >
        <PivotItem x:Uid="PivotItem_OnNow">
            <Frame>
                <views:OnNowPage/>
            </Frame>
        </PivotItem>
        <PivotItem x:Uid="PivotItem_Guide">
            <Frame>
                <views:GuidePage/>
            </Frame>
        </PivotItem>
        <PivotItem x:Uid="PivotItem_Settings">
            <Frame>
                <views:SettingsPage/>
            </Frame>
        </PivotItem>
    </Pivot>
</Grid>
<Grid>
    <Grid Margin="{StaticResource MediumLeftRightMargin}">
        <Grid.RowDefinitions>
            <RowDefinition Height="48"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <TextBlock
            Grid.Row="0"
            x:Uid="Settings_Title"
            x:Name="TitlePage"
            Style="{StaticResource PageTitleStyle}" />

        <StackPanel Grid.Row="1">
            <TextBlock
                x:Uid="Settings_Personalization"
                Style="{StaticResource SubtitleTextBlockStyle}" />

            <StackPanel Margin="{StaticResource SettingsSubheaderMargin}">
                <TextBlock
                    x:Uid="Settings_Theme"
                    Style="{StaticResource BodyTextStyle}" />

                <StackPanel Margin="{StaticResource EightTopMargin}">
                    <RadioButton
                        x:Uid="Settings_Theme_Light"
                        GroupName="AppTheme"
                        IsChecked="{x:Bind ViewModel.ElementTheme, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter=Light, Mode=OneWay}"
                        Command="{x:Bind ViewModel.SwitchThemeCommand}">
                        <RadioButton.CommandParameter>
                            <xaml:ElementTheme>Light</xaml:ElementTheme>
                        </RadioButton.CommandParameter>
                    </RadioButton>
                    <RadioButton
                        x:Uid="Settings_Theme_Dark"
                        GroupName="AppTheme"
                        IsChecked="{x:Bind ViewModel.ElementTheme, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter=Dark, Mode=OneWay}"
                        Command="{x:Bind ViewModel.SwitchThemeCommand}">
                        <RadioButton.CommandParameter>
                            <xaml:ElementTheme>Dark</xaml:ElementTheme>
                        </RadioButton.CommandParameter>
                    </RadioButton>
                    <RadioButton
                        x:Uid="Settings_Theme_Default"
                        GroupName="AppTheme"
                        IsChecked="{x:Bind ViewModel.ElementTheme, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter=Default, Mode=OneWay}"
                        Command="{x:Bind ViewModel.SwitchThemeCommand}">
                        <RadioButton.CommandParameter>
                            <xaml:ElementTheme>Default</xaml:ElementTheme>
                        </RadioButton.CommandParameter>
                    </RadioButton>
                </StackPanel>
            </StackPanel>

            <TextBlock
                    x:Uid="Settings_About"
                    Style="{StaticResource SubtitleTextBlockStyle}"/>

            <StackPanel Margin="{StaticResource EightTopMargin}">
                <TextBlock
                    Text="{x:Bind ViewModel.VersionDescription, Mode=OneWay}" />
                <TextBlock
                    x:Uid="Settings_AboutDescription"
                    Margin="{StaticResource EightTopMargin}" />

                <HyperlinkButton
                    x:Uid="Settings_PrivacyTermsLink"
                    Margin="{StaticResource EightTopMargin}" />
            </StackPanel>
        </StackPanel>
    </Grid>
</Grid>

设置.xaml

<Grid x:Name="MainGrid">
    <Pivot x:Uid="PivotPage" x:Name="MainPivot" >
        <PivotItem x:Uid="PivotItem_OnNow">
            <Frame>
                <views:OnNowPage/>
            </Frame>
        </PivotItem>
        <PivotItem x:Uid="PivotItem_Guide">
            <Frame>
                <views:GuidePage/>
            </Frame>
        </PivotItem>
        <PivotItem x:Uid="PivotItem_Settings">
            <Frame>
                <views:SettingsPage/>
            </Frame>
        </PivotItem>
    </Pivot>
</Grid>
<Grid>
    <Grid Margin="{StaticResource MediumLeftRightMargin}">
        <Grid.RowDefinitions>
            <RowDefinition Height="48"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <TextBlock
            Grid.Row="0"
            x:Uid="Settings_Title"
            x:Name="TitlePage"
            Style="{StaticResource PageTitleStyle}" />

        <StackPanel Grid.Row="1">
            <TextBlock
                x:Uid="Settings_Personalization"
                Style="{StaticResource SubtitleTextBlockStyle}" />

            <StackPanel Margin="{StaticResource SettingsSubheaderMargin}">
                <TextBlock
                    x:Uid="Settings_Theme"
                    Style="{StaticResource BodyTextStyle}" />

                <StackPanel Margin="{StaticResource EightTopMargin}">
                    <RadioButton
                        x:Uid="Settings_Theme_Light"
                        GroupName="AppTheme"
                        IsChecked="{x:Bind ViewModel.ElementTheme, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter=Light, Mode=OneWay}"
                        Command="{x:Bind ViewModel.SwitchThemeCommand}">
                        <RadioButton.CommandParameter>
                            <xaml:ElementTheme>Light</xaml:ElementTheme>
                        </RadioButton.CommandParameter>
                    </RadioButton>
                    <RadioButton
                        x:Uid="Settings_Theme_Dark"
                        GroupName="AppTheme"
                        IsChecked="{x:Bind ViewModel.ElementTheme, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter=Dark, Mode=OneWay}"
                        Command="{x:Bind ViewModel.SwitchThemeCommand}">
                        <RadioButton.CommandParameter>
                            <xaml:ElementTheme>Dark</xaml:ElementTheme>
                        </RadioButton.CommandParameter>
                    </RadioButton>
                    <RadioButton
                        x:Uid="Settings_Theme_Default"
                        GroupName="AppTheme"
                        IsChecked="{x:Bind ViewModel.ElementTheme, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter=Default, Mode=OneWay}"
                        Command="{x:Bind ViewModel.SwitchThemeCommand}">
                        <RadioButton.CommandParameter>
                            <xaml:ElementTheme>Default</xaml:ElementTheme>
                        </RadioButton.CommandParameter>
                    </RadioButton>
                </StackPanel>
            </StackPanel>

            <TextBlock
                    x:Uid="Settings_About"
                    Style="{StaticResource SubtitleTextBlockStyle}"/>

            <StackPanel Margin="{StaticResource EightTopMargin}">
                <TextBlock
                    Text="{x:Bind ViewModel.VersionDescription, Mode=OneWay}" />
                <TextBlock
                    x:Uid="Settings_AboutDescription"
                    Margin="{StaticResource EightTopMargin}" />

                <HyperlinkButton
                    x:Uid="Settings_PrivacyTermsLink"
                    Margin="{StaticResource EightTopMargin}" />
            </StackPanel>
        </StackPanel>
    </Grid>
</Grid>

轻的
黑暗的
违约
列出了XY导航可能无法按预期方式工作的几种情况:

  • IsTabStop或Visibility属性设置错误
  • 获取焦点的控件实际上比您想象的要大,XY导航查看控件的总大小(实际宽度和实际高度),而不仅仅是控件中呈现有趣内容的部分
  • 一个可聚焦控件位于另一个XY导航控件之上,不支持重叠的控件
  • 如果XY导航在解决这些问题后仍无法按预期方式工作,则可以使用中描述的方法手动指向要获取焦点的元素

    请先检查这些场景,然后,如果您仍然无法解决此问题。请提供。我将帮助您在我这边进行诊断。

    列出了XY导航可能无法按您预期的方式工作的几种情况:

  • IsTabStop或Visibility属性设置错误
  • 获取焦点的控件实际上比您想象的要大,XY导航查看控件的总大小(实际宽度和实际高度),而不仅仅是控件中呈现有趣内容的部分
  • 一个可聚焦控件位于另一个XY导航控件之上,不支持重叠的控件
  • 如果XY导航在解决这些问题后仍无法按预期方式工作,则可以使用中描述的方法手动指向要获取焦点的元素

    请先检查这些场景,然后,如果您仍然无法解决此问题。请提供。我会帮你帮我诊断的