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

Command binding in button not working

$
0
0

Using Xamarin Forms with Visual Studio 2017.

Button click on iOS is not calling the Command action.

It works on Android but iOS not.

I am using Linker Behavior: Link All

This is my code:

XAML

 <StackLayout Orientation="Vertical" >
                                <Button x:Name="btnSignIn" Text="Log in" BackgroundColor="#0072BD" TextColor="White" FontSize="20" FontAttributes="Bold"  HorizontalOptions="CenterAndExpand" Command="{Binding LoginCommand}"/>
                            </StackLayout>

XAML.cs

public LoginPage()
    {
            InitializeComponent();         
            BindingContext = viewModel = new LoginPageViewModel();
            viewModel.Navigation = this.Navigation;
            PasswordEntry.Text = string.Empty;

            EmailEntry.Focus();
            EmailEntry.Completed += (s, e) => PasswordEntry.Focus();           
            switchRemember.Toggled += switchremember_toggled;
    }

ViewModel

            public LoginPageViewModel()
                {
                        RememberChecked = false;
                       LoginCommand = new Command(Login);          
                        IsBusy = false;
                }

    public async void Login()
        {

                if (Settings.IsConnected)
                {
                    IsBusy = true;

                  ..... //Complementary code

                    IsBusy = false;
                }
                else
                    ShowAlert("Failed connection", "Check your internet connection.");

        }

I tried the answer from @christopherpolska
https://forums.xamarin.com/discussion/88071/mvvmcross-not-binding-barbutton-click-event-on-device

but didn´t work for me.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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