Xamarin Forms : Click Events dont get fired

Vuyiswa Maseko 351 Reputation points
2020-12-27T09:11:16.7+00:00

Good Day All

i have two buttons , one is a Sysfusion and one a normal generic button

<StackLayout>
<buttons:SfButton x:Name="btn2"

                           BackgroundColor="{DynamicResource PrimaryColor}" 
                                CornerRadius="20"
                                HeightRequest="40" 
                              Clicked="btnsend_Clicked"
                                HorizontalOptions="End" 
                                VerticalOptions="End"
                                WidthRequest="40"> 
                        </buttons:SfButton>


                    <Button Text="Send"    x:Name="btn2"       
                           BackgroundColor="{DynamicResource Blue}" 
                                CornerRadius="20"
                                HeightRequest="40"  
                                HorizontalOptions="End"
                                VerticalOptions="End"
                                WidthRequest="40" Clicked="chat_send">
                        </Button>
                    </StackLayout> 

btn1 click event does not get fired but click event which is the same method for btn2 gets fired.

Thanks

Developer technologies .NET Xamarin
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,756 Reputation points
    2020-12-28T05:32:47.533+00:00

    Hello,

    Welcome to Microsoft Q&A!

    1. You set x:name as btn2 on both two buttons , which is btn1? Do you mean SfButton ?
    2. Which platform did you test on ? iOS ,Android ,UWP ? If it is iOS and UWP/WPF , you need additional step to use SfButton, check here . For example , in iOS you need to init the renderer in AppDelegate . public override bool FinishedLaunching(UIApplication app, NSDictionary options)
      {
      global::Xamarin.Forms.Forms.Init();
      LoadApplication(new App());
      Syncfusion.XForms.iOS.Border.SfBorderRenderer.Init();
      Syncfusion.XForms.iOS.Buttons.SfButtonRenderer.Init();
      return base.FinishedLaunching(app, options);
      }

    Thank you.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.