1

我开发了一个使用登录表单的通用应用程序,允许用户连接或创建帐户。

这是一个简单的页面,如下所示: 在此处输入图像描述

这个 XAML 代码也很简单:

    <ScrollViewer>
        <StackPanel>
            <TextBlock x:Uid="loginRegisterTextblockMessage" 
                       Style="{StaticResource TitleTextBlockStyle}" 
                       Text="Remplissez vos informations d'inscription" />
            <TextBox x:Uid="loginRegisterTextboxOrganizationURL"
                     Header="Organisation ou URL"
                     IsSpellCheckEnabled="False"
                     IsHitTestVisible="True"
                     IsTextPredictionEnabled="False"
                     Text="{Binding OrganizationURL, Mode=TwoWay}" />
            <TextBox x:Uid="loginRegisterTextboxLastName"  
                     Header="Nom"
                     Text="{Binding LastName, Mode=TwoWay}" />
            <TextBox x:Uid="loginRegisterTextboxFirstName" 
                     Header="Prénom"
                     Text="{Binding FirstName, Mode=TwoWay}" />
            <TextBox x:Uid="loginRegisterTextboxEmail" 
                     Header="Email"
                     InputScope="EmailSmtpAddress"
                     Text="{Binding Email, Mode=TwoWay}"/>
            <PasswordBox x:Uid="loginRegisterPasswordboxPassword" 
                         Header="Mot de passe"
                         Password="{Binding Password, Mode=TwoWay}" />
            <PasswordBox x:Uid="loginRegisterPasswordboxConfirmPassword" 
                         Header="Confirmez le mot de passe"
                         Password="{Binding PasswordConfirmation, Mode=TwoWay}" />
            <CheckBox x:Uid="loginRegisterCheckboxTermsOfUse" 
                      IsChecked="{Binding TermsOfUse, Mode=TwoWay}" >
                <TextBlock Style="{StaticResource BaseTextBlockStyle}">
                    <Run x:Uid="loginRegisterTextblockTermsOfUse1" 
                         Text="J'accepte les " />
                    <Underline>
                        <Hyperlink x:Uid="loginRegisterHyperlinkTermsOfUse" 
                                   NavigateUri="http://termsofuse.html" >
                            <Run x:Uid="loginRegisterTextblockTermsOfUse2" 
                                 Text="conditions générales d'utilisation" />
                        </Hyperlink>
                    </Underline>
                </TextBlock>
            </CheckBox>
            <Button x:Uid="loginRegisterButtonRegister"
                    Content="S'inscrire" 
                    Command="{Binding RegisterCommand}" />
        </StackPanel>
    </ScrollViewer>

但是我遇到了在此页面的每个字段之间导航的“问题”: 在此处输入图像描述

=> 用户必须在 TextBlock 外部单击才能隐藏键盘并选择下一个字段:这不是很人性化

我查看了一个类似的“系统”表单:用于创建访问 Windows 应用商店的帐户的页面。

该页面看起来与我自己的页面非常相似: 在此处输入图像描述

但是可以通过单击其标题来激活下一个字段:

在此处输入图像描述

焦点在字段上移动,键盘也自动显示: 在此处输入图像描述

如果我点击下一个标题“ Nom d'utilisateur ”,我可以看到下一个字段现在是“ Domaine ”,通过自动移动到显示的内容: 在此处输入图像描述

=> 有没有一种简单的方法可以重现这种行为?它是基于“文本框”的“标题”,还是使用单独的“文本块”来显示标题?

4

1 回答 1

0

我一直在寻找一个好的解决方案,但我没有找到。我在 XAML 中为GetFocusKeyDown上的TextBoxPasswordBox添加了事件。在 Code-Behind 中,我现在可以管理“Enter”键,它将焦点转移到下一个TextBox

        private void RegisterTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
    {
        TextBox currentTextBox = (TextBox)sender;
        if (currentTextBox != null)
        {
            if (e.Key == Windows.System.VirtualKey.Enter)
            {
                FocusManager.TryMoveFocus(FocusNavigationDirection.Next);
            }
        }
    }

但我还没有像我希望的那样管理 ScrollViewer 自动滚动。我试图从这个链接中启发我,但无济于事: Keyboard-Overlaps-Textbox

=> 真的有办法重现 Windows 应用商店注册表单上使用的自动滚动吗?

于 2015-10-15T12:54:10.857 回答