thejdah
thejdah

Reputation: 345

Xamarin - Have button call keyboard

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?

Upvotes: 2

Views: 506

Answers (2)

ColeX
ColeX

Reputation: 14475

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>

Upvotes: 0

Jason
Jason

Reputation: 89117

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(); };

Upvotes: 1

Related Questions