简体   繁体   English

打开键盘时查看所有元素-Windows 10移动版-XAML-C#

[英]See all elements when Keyboard Open - Windows 10 Mobile - XAML - C#

I am developing a page and I have some doubts. 我正在开发一个页面,我对此有些怀疑。 My project is for Windows 10 Mobile. 我的项目适用于Windows 10移动版。 On the page that I am developing, when a textbox has the focus, the mobile phone keyboard up and I get the rest of the hidden elements, and does not allow me to scroll will poara page to see all the elements. 在我正在开发的页面上,当一个文本框具有焦点时,将手机键盘抬起,我将获得其余的隐藏元素,并且不允许我滚动查看页面中的所有元素。

Ja walked to do on the internet, but I saw that the solutions depend on ensuring greater size to my StackPanel than to my ScrolViewer but I do not need it as well. Ja走路去上网,但是我看到解决方案取决于确保我的StackPanel的尺寸大于我的ScrolViewer的尺寸,但我也不需要它。 eg ScrollViewer Width = 500 ... StackPanel Width = 700 例如ScrollViewer Width = 500 ... StackPanel Width = 700

When the keypad on'd like to be able to see all the elements, making the scroll. 当键盘上的键盘希望能够看到所有元素时,进行滚动。

Follows my code: 遵循我的代码:

    <ScrollViewer x:Name="ScrollViewerTest VerticalAlignment="Top">
            <StackPanel Orientation="Vertical" Margin="10,10,10,10">

                    <TextBox x:Name="txtUserNameMobile" IsSpellCheckEnabled="False" 
                             Background="Black" Foreground="White"
                             PlaceholderText="Insert your text"
                             />

                    <Button x:Name="btnHere" 
                            Content="btnHere" 
                            Height="48"
                            Width="150">

                    <Button x:Name="btnHere2" 
                            Content="btnHere2" 
                            Height="48"
                            Width="150">

                    <Button x:Name="btnHere3" 
                            Content="btnHere3" 
                            Height="48"
                            Width="150">

                    <Button x:Name="btnHere4" 
                            Content="btnHere4" 
                            Height="48"
                            Width="150">

                     <Button x:Name="btnHere5" 
                            Content="btnHere5" 
                            Height="48"
                            Width="150">
        </StackPanel>
</ScrollViewer>

Someone can help me? 有人可以帮我吗?

The default scrolling behavior of the page on TextBox focus can be overridden and custom logic can be added to show the focused TextBox when keyboard is shown. 可以覆盖TextBox焦点上页面的默认滚动行为,并且可以添加自定义逻辑以在显示键盘时显示焦点突出的TextBox Using this method the ScrollViewer can be made to scroll when keyboard is open. 使用此方法,可以在打开键盘时使ScrollViewer滚动。

InputPane.GetForCurrentView().Showing += InputPane_Showing;

private void InputPane_Showing(InputPane sender, InputPaneVisibilityEventArgs args)
        {
             args.EnsuredFocusedElementInView = true; //This will prevent the auto scroll of the page.
        }

args.OccludedRect will give the properties related to the keyboard like height, top position etc. These values can be used to move the TextBox to the required position if it is hidden behind the keyboard. args.OccludedRect将提供与键盘相关的属性,例如高度,顶部位置等。这些值可用于将TextBox移动到所需位置(如果它隐藏在键盘后面)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM