XFFacebookLoginButtonExample icon indicating copy to clipboard operation
XFFacebookLoginButtonExample copied to clipboard

Xamarin Forms custom login button bindable properties not set

Open alperenbabagil opened this issue 6 years ago • 0 comments

Hi, First of all thanks for this great tutorial. I implemented the facebook login button but after clicking and completing login OnSuccess,OnFail and OnError callbacks not triggered on viewModel. After some digging code realized that custom view bindable properties not set. So triggering callbacks in native side stopped because custom view's properties is null. So I changed little bit and putting one example for a Binding Property of custom login button. Happy coding!

FacebookLoginButton.cs:

        // this is the Bindable property. Added property changed property to set manually
        public static readonly BindableProperty OnSuccessProperty =
            BindableProperty.Create(nameof(OnSuccess), typeof(Command<string>), typeof(FacebookLoginButton), propertyChanged: OnSuccessPropertyChanged);

        static void OnSuccessPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            ((FacebookLoginButton)bindable).OnSuccessPropertyChanged((Command<string>)oldValue, (Command<string>)newValue);
        }

        void OnSuccessPropertyChanged(Command<string> oldValue, Command<string> newValue)
        {
            OnSuccess = newValue; //setting command value
        }

alperenbabagil avatar Oct 19 '19 10:10 alperenbabagil