【问题标题】:Can't get keyboard focus/tab order to hyperlink when tabbing fwd选项卡前进时无法获得键盘焦点/选项卡顺序以超链接
【发布时间】:2011-03-22 22:31:49
【问题描述】:

我在修复 WPF 应用程序中的超链接时遇到了一个错误,该超链接无法通过选项卡进入。前进时会跳过该控件,但如果您向后按 Tab(shift-tab),则链接将获得焦点!

该窗口设置有几个面板:链接所在的顶部面板(用户控件)、下方包含表单内容的主面板以及右侧的工具栏。 Tabbing fwd 将使所有这些控件正常,但跳过顶部面板。如果你 shift-tab,你会得到超链接。

帮助?

<Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
        <RowDefinition x:Name="gridRowBanner" Height="71"/>
        <RowDefinition x:Name="gridRowFormContent"/>           
    </Grid.RowDefinitions>

    <UserControl FocusManager.IsFocusScope="True" KeyboardNavigation.TabNavigation="Continue"/>

    <TabControl Grid.Row="1" TabStripPlacement="Left" >

用户控件有这个项目,当你前进时没有获得焦点,但当你后退时:

        <TextBlock x:Name="textParentWorkItem" HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Row="2" Grid.Column="1" >
            <Hyperlink Cursor="Hand" Click="Hyperlink_Click" x:Name="linkParentWorkItem" KeyboardNavigation.IsTabStop="True" >
                <InlineUIContainer>                                
                    <TextBlock Text="{Binding ParentWorkItem[0].DisplayName, Mode=OneWay}" />
                </InlineUIContainer>
            </Hyperlink>
        </TextBlock>

【问题讨论】:

    标签: wpf keyboard focus


    【解决方案1】:

    想通了。我在 UserControl 上有这个:

    FocusManager.FocusedElement="{Binding ElementName=tabItemGeneral}"

    删除它并且焦点有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-08
      • 2020-03-22
      • 2011-12-26
      • 1970-01-01
      • 2013-10-02
      • 1970-01-01
      相关资源
      最近更新 更多