Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Trying to make 'Next' and 'Prev' buttons on Keyboard through Custom Renderer. Any suggestions?

$
0
0

So I'm trying to test if I can make the Next button on my keyboard go to the next Entry.

image

My Done, Next, and Previous buttons on the keyboard were made using Custom Renderer for iOS. Here's the code that I used:

using System;
using Xamarin.Forms;
using CustomRendererKeyboard;
using CustomRendererKeyboard.iOS;
using Xamarin.Forms.Platform.iOS;
using MonoTouch.UIKit;
using System.Drawing;

[assembly:ExportRenderer(typeof(MyEntry), typeof(MyEntryRenderer))]

namespace CustomRendererKeyboard.iOS
{
    public class MyEntryRenderer : EntryRenderer
    {

        protected override void OnElementChanged(ElementChangedEventArgs<Entry> args)
        {
            base.OnElementChanged (args);


            UIToolbar toolBar = new UIToolbar (new RectangleF (0.0f, 0.0f, this.Frame.Size.Width, 44.0f));
            toolBar.Translucent = true;
            toolBar.Items = new UIBarButtonItem[] {
                new UIBarButtonItem("Prev", UIBarButtonItemStyle.Bordered, delegate {
                    //How to make cursor go to previous Entry??
                }),
                new UIBarButtonItem("Next", UIBarButtonItemStyle.Bordered, delegate {
                    //How to make cursor go to next Entry??
                }),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem (UIBarButtonSystemItem.Done, delegate {
                    this.Control.ResignFirstResponder();
                })
            };

            this.Control.InputAccessoryView = toolBar;

        }
    }
}

So my problem is, how can I access the Entry in my xaml because it seems that if I add a custom renderer for my controls, Xamarin won't allow me to add an x:Name to my entry. I get an " Error: Error executing task XamlG: Can't load types from xmlns clr-namespace:CustomRendererKeyboard;assembly=CustomRendererKeyboard (CustomRendererKeyboard)"

Is there a way to access something like NextEntry.Focus(); but inside a custom renderer? I would appreciate some insights. Thank you!


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>