Я перемещаю фокус с Entry
на другой Entry
внутри AbsoluteLayout
с помощью нажатия кнопки.
При каждой фокусировке навигация клавиатуры скрывается и снова возвращается к видимости. Я хочу, чтобы клавиатура не скрывалась, если следующий дочерний объект должен быть сфокусирован на Entry
.
Xaml код
<Grid>
<ScrollView>
<local:CustomLayout
x:Name="entryStack"
BindableLayout.ItemsSource="{Binding SomeItems}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Entry
WidthRequest="100"
Focused="Entry_Focused"/>
</DataTemplate>
</BindableLayout.ItemTemplate>
</local:CustomLayout>
</ScrollView>
<Button VerticalOptions="Start" HorizontalOptions="End" Text="NextField" Clicked="Button_Clicked"/>
</Grid>
CustomLayout
наследование AbsoluteLayout
public class CustomLayout : AbsoluteLayout
{
public CustomLayout()
{
}
protected override void OnChildAdded(Element child)
{
base.OnChildAdded(child);
var childElement = (child as View);
var index = this.Children.IndexOf(childElement);
childElement.TranslationY = index * 30;
}
}
Xaml.cs
public partial class MainPage : ContentPage
{
public List<string> SomeItems { get; set; }
int i = 0;
public MainPage()
{
InitializeComponent();
this.SomeItems = new List<string>()
{
"One",
"One",
"One",
"One",
"One",
"One",
"One",
"One",
"One",
"One",
"One",
"One",
"One",
"One",
};
this.BindingContext = this;
}
void Button_Clicked(System.Object sender, System.EventArgs e)
{
i = i+1;
(entryStack.Children[i] as Entry).Focus();
}
void Entry_Focused(System.Object sender, Xamarin.Forms.FocusEventArgs e)
{
i = entryStack.Children.IndexOf((sender as Entry));
}
}
![enter image description here](https://i.stack.imgur.com/1mFVO.gif)
Является ли это можно достичь. Я что-то здесь не так делаю ??