加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows-phone-7 – 当键盘处于活动状态时,ScrollViewer不会向上

发布时间:2020-12-14 05:41:56 所属栏目:Windows 来源:网络整理
导读:如何在 Windows Phone中获取表单行为,如设置移动网络 EditAPN.在此页面中,它在scrollviewer中有许多文本框.当用户点击任何文本框并获得焦点时,页面向上滚动并且页眉保持不变并显示SIP键盘.当用户从此文本框中丢失焦点时,页面将进入正常状态,SIP键盘隐藏和标
如何在 Windows Phone中获取表单行为,如设置>>移动网络>> EditAPN.在此页面中,它在scrollviewer中有许多文本框.当用户点击任何文本框并获得焦点时,页面向上滚动并且页眉保持不变并显示SIP键盘.当用户从此文本框中丢失焦点时,页面将进入正常状态,SIP键盘隐藏和标题保持不变.我想实现这种行为.我搜索了很多但没有得到任何解决方案.
很奇怪在WP7中看到scrollviewer行为.
任何帮助都将是伟大而可观的.
提前致谢.
注意:如果有任何棘手的解决方案,请提供示例代码.

这是我的示例代码.

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

当我尝试向下滚动时,它不会完全向下移动,看起来像弹性一样.

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

解决方法

也许我错了,但为什么不使用简单的网格和listpicker控件.您将需要Windows Phone Toolkit(Nuget Here).

网格的第一行包含标题,不会更改.
第二行包含您想要的内容(scrollview,listpicker,…)

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

<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,28">
            <TextBlock x:Name="PageTitle" Text="MY HEADER" Margin="9,-7,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布局系统将解决问题.

这个example可以帮到你.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读