Xamarin - Have button call keyboard

Viewed 203

I am building an app with Xamarin. On the image below, the top row has 6 buttons. The bottom row has 6 keyboard entries.

enter image description here

I would like for the keyboard entry to be called when the button above it is pressed. This would call for each button and keyboard to have its own ID, and each button to have a function that would call its respective keyboard. But that's as far as I can get. I cannot figure out how to write the function for the button to call the keyboard.

How would I write the function to call the keyboard? Can someone provide an example?

2 Answers

for each pair of Button/Entry do something like this

Button btnA = new Button { Text = "AA" };
Entry entryA = new Entry();

btnA.Clicked += (s,a) { entryA.Focus(); };

You can wrap the Button and Entry into a custom contentView , then the button click would call the respective keyboard .

Custom view

x:Class="MyForms.View.MyView"

<StackLayout>
   <Button Clicked="Button_Clicked" Text="{Binding .}" HorizontalOptions="CenterAndExpand"/>
   <Entry x:Name="entry" WidthRequest="100"/>
</StackLayout>

private void Button_Clicked(object sender, EventArgs e)
{
   entry.Focus();
}

Page

<CollectionView ItemsLayout="HorizontalList" ItemsSource="{Binding list}">
  <CollectionView.ItemTemplate>
     <DataTemplate>
        <local:MyView/>
     </DataTemplate>
  </CollectionView.ItemTemplate>
</CollectionView>
Related