键盘处于活动状态时 ScrollViewer 不会向上滚动 [英] ScrollViewer does not scroll up while Keyboard is active

查看:26
本文介绍了键盘处于活动状态时 ScrollViewer 不会向上滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Windows Phone 中获取表单行为,例如设置 >> 移动网络 >> EditAPN.在此页面中,滚动查看器中有许多文本框.当用户点击任何文本框并获得焦点时,页面会向上滚动,标题保持不变并显示 SIP 键盘.当用户从这个文本框中失去焦点时,页面进入正常状态,SIP 键盘隐藏,标题保持不变.我想实现这种行为.我搜索了很多,但没有得到任何解决方案.在 WP7 中看到滚动查看器的行为很奇怪.任何帮助都将是巨大而可观的.提前致谢.注意:如果有任何棘手的解决方案,请提供示例代码.

How I can get behavior of form in windows Phone like Settings >> Mobile Network >> EditAPN. In this page it have many textboxes in scrollviewer. When user taps on any textbox and its get focus then the page scrolls up and header remains constant and SIP keyboard shown. And when user lost the focus from this text box then page comes to its normal state and SIP keyboard hides and header remains unchanged. I want to achieve this behavior. I searched a lot but did not get any solution. Strange to see scrollviewer behavior in WP7. Any help will be great and appreciable. Thanks in advance. Note: If there is any tricky solution, please provide sample code.

这是我的示例代码.

<Grid x:Name="ContentPanel" Grid.Row="1" >
            <ScrollViewer x:Name="Scroller">
                <StackPanel Orientation="Vertical">

                    <TextBlock Text="Name"/>
                    <TextBox x:Name="txtName" />
                    <TextBlock Text="Email"/>
                    <TextBox x:Name="txtEmail"/>
                    <TextBlock Text="Phone"/>
                    <TextBox x:Name="txtPhone" />
                    <TextBlock Text="Adress"/>
                    <TextBox x:Name="txtAddress" />                 

                </StackPanel>
            </ScrollViewer>
        </Grid>

当我尝试向下滚动时,它没有完全向下移动,并且似乎具有弹性.

When I try to scroll down, it does not move down fully and seems to be worked as elastic.

这个例子,我已经看过了,对我来说没有用.我有 4 个文本框,我的重点是第一个文本框,键盘出现并隐藏最后一个文本框.如果用户想要转到最后一个文本框并想要输入输入,它不会完全滚动并且具有弹性.对于这个用户必须按下屏幕的其他部分,然后他在最后一个框中输入.我在设置"->移动网络"->EditAPN"中的 WP7 应用程序中看到了.有 4-5 个文本框,这些文本框滚动得很好.不知道 MSFT 使用了哪个控件或解决方法.

This example, I have already seen and not useful in my case. I have 4 textboxes and my focus is on first textbox and keypad comes and hide last textbox. If user wants to go to last textbox and wants to enter input, it does not scroll fully and works as elastic. For this user has to press on some other part of screen, then he enter in last box. I saw in WP7 app in Settings -> Mobile Network -> EditAPN. There are 4-5 text boxes and these scroll perfectly. Don't know Which control or workaround MSFT used.

推荐答案

也许我错了,但为什么不使用简单的网格和列表选择器控件.为此,您将需要 Windows Phone 工具包(Nuget 此处).

Maybe I am wrong, but why not using a simple grid and a listpicker control. You will need the Windows Phone Toolkit for this (Nuget Here).

网格的第一行包含标题并且不会改变.第二行包含您想要的内容(滚动视图、列表选择器...)

The first Row of the grid contains the Header and will not change. The second Row contains what you want (scrollview, listpicker, ...)

这是一个非常基本的例子:

Here is a very basic example :

<phone:PhoneApplicationPage 
    x:Class="PhoneApp3.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="PageTitle" Text="MY HEADER" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <Grid x:Name="ContentPanel" Grid.Row="1">
            <toolkit:ListPicker>
                <toolkit:ListPickerItem Content="aaa" />
                <toolkit:ListPickerItem Content="bbb" />
                <toolkit:ListPickerItem Content="ccc" />
            </toolkit:ListPicker>
        </Grid>
    </Grid>
</phone:PhoneApplicationPage>

在呈现 SIP 键盘时,PhoneApplicationFrame.TranslateTransform.Y 设置为特定值(横向 -259,纵向 -339).要更新布局,我们只需将上边距设置为指定值(-s),然后 Silverlight 布局系统将修复该问题.

这个示例可能对您有所帮助.

This example may help you.

这篇关于键盘处于活动状态时 ScrollViewer 不会向上滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆