0
votes

My page looks like this:

enter image description here

If the user focus one of the entries, page is "locked". The user can't move up or down as it follows:

enter image description here

I've used ContentPage with ScrollView as a main layout. I've also tried to set Window.SetSoftInputMode() in various modes, but everything remains the same.

Is there any modular way to fix this (I have workaround with a StackLayout above entries with HeightRequest=0, when one of the entries is focused, I change HeightRequest to the height of keyboard) ?

3
Did you find any solution for this problem?MohamedHarmoush
Yes, something for my specific problem. Check the answer below.zpouip

3 Answers

0
votes

You can also manually scroll your page using below code

void EntryKeyboardHandle_Focused(object sender, Xamarin.Forms.FocusEventArgs e)
        {
            Device.BeginInvokeOnMainThread(async () =>
            {
                var height = SignupGrid.Height;
                await MainScroll.ScrollToAsync(0, height, true);
            });
        }

You need to put your grid or stacklayout in scroll view and put focus event on entry.

Focused="EntryKeyboardHandle_Focused"
0
votes

Use Xam.Plugins.Forms.KeyboardOverlap plugin only in your iOS Project (not PCL, not Android), and you iOS Project call:

Xamarin.Forms.Init();//platform specific init
KeyboardOverlapRenderer.Init ();

You must do this AFTER you call Xamarin.Forms.Init().

enter image description here

Here are an example: https://github.com/paulpatarinski/Xamarin.Forms.Plugins/tree/master/KeyboardOverlap/SampleApp

0
votes

UPDATE: Added new custom control CustomEntry which is basically default Entry with extended functionality:

<?xml version="1.0" encoding="UTF-8"?>
<Entry xmlns="http://xamarin.com/schemas/2014/forms"
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
       x:Class="MyApp.Framework.Controls.CustomEntry"
       TextColor="{StaticResource MainPurple}"
       PlaceholderColor="{StaticResource MainPurpleLight}"
       HeightRequest="45"
       FontSize="14"
       Focused="CustomEntryFocused"
       Unfocused="CustomEntryUnfocused">    
</Entry>

And then set Focus and Unfocus methods on this entry:

private void CustomEntryFocused(object sender, FocusEventArgs e)
{
    var stackParent = StackParent as StackLayout;
    stackParent?.Children.Add(new StackLayout() { HeightRequest = `KeyboardHeight });
}

private void CustomEntryUnfocused(object sender, FocusEventArgs e)
{
    var stackParent = StackParent as StackLayout;               
    stackParent?.Children.RemoveAt(stackParent.Children.Count - 1);
}