ScrollViewer does not scroll while keyboard is active

How can I get the form behavior in Windows Phone as Settings β†’ Mobile Network β†’ EditAPN. On this page, it has many text fields in scrollviewer. When the user clicks on any text field and receives focus, the page scrolls up, and the title remains constant and the SIP keyboard is displayed. And when the user has lost focus from this text box, the page goes to normal, and the SIP keyboard hides, and the title remains unchanged. I want to achieve this behavior. I searched a lot, but did not get any solution. It's weird to see scrollviewer behavior in WP7. Any help would be great and noticeable. Thank you in advance. Note. If there is any complicated solution, provide a sample code.

Here is my 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 doesn't completely fall and seems to work as elastic.

Edit: This example, I have already seen and is not useful in my case. I have 4 text boxes, and I'm focused on the first text box, and the keyboard comes in and hides the last text box. If the user wants to go to the last text field and wants to enter an input, he does not scroll completely and works as elastic. For this user, you need to click on some other part of the screen, then he will enter the last square. I saw in the WP7 application in Settings β†’ Mobile Network β†’ EditAPN. There are 4-5 text fields, and they scroll perfectly. I do not know what control or time interval is used by MSFT.

+4
source share
1 answer

Maybe I'm wrong, but why not use a simple grid and listpicker control. To do this, you will need the Windows Phone Toolkit (Nuget here ).

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

Here is a very simple 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> 

Edit:

When the SIP keyboard is displayed, PhoneApplicationFrame.TranslateTransform.Y is set to certain values ​​(-259 in landscape orientation, -339 in portrait orientation). To refresh the layout, simply set the top edge to the specified value (-s), and then the Silverlight layout system will fix the problem.

This example may help you.

+1
source

All Articles