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

How change Keyboard of entry inside user control Xamarin Fom

$
0
0

I can not change the entry keyboard inside user conttrol

IMPLEMENTATION

User control

xml:

<?xml version="1.0" encoding="utf-8" ?>
<ContentView
         xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
         xmlns:control="clr-namespace:Projecro_3.ControlCostumiado"
         prism:ViewModelLocator.AutowireViewModel="True"     
         Padding="10"
         x:Class="Projecro_3.Controls.EntryControl">

 <AbsoluteLayout>

           <control:CustomEntry x:Name="entry">  </control:CustomEntry>             
</AbsoluteLayout>
</ContentView>

Classe:

namespace Projecro_3.Controls
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class EntryControl : ContentView, INotifyPropertyChanged
    {

        public Keyboard Teclado { get; set; }
        public static readonly BindableProperty TecladoProperty = BindableProperty.Create(
                                                   propertyName: "Teclado",
                                                   returnType: typeof(Keyboard),
                                                   declaringType: typeof(EntryControl),
                                                   defaultValue: Keyboard.Default,
                                                   defaultBindingMode: BindingMode.TwoWay,
                                                   propertyChanged: TecladoPropertyChanged);


        public EntryControl()
        {
            InitializeComponent(); 
            entry.BindingContext = this;
        }

        private static void TecladoPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var control = (EntryControl)bindable;
            if (control == null) return;
            control.entry.Keyboard = (Keyboard)newValue;
        }  
    }
}

MainPage

<control:EntryControl Grid.Row="0" Teclado="Numeric" WidthRequest="180" PathIconeInicial="lock.png" Titulo="Alegria" Placeholder="Number" ></control:EntryControl>

I set the numeric keyboard, it prevents typing texts but does not change keyboard.


Viewing all articles
Browse latest Browse all 89864

Trending Articles



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