0
votes

I am very new to Xamarin. I need to add a image button that display Facebook icon on my Xamarin app and when the user clicks on that icon, I need to be redirected to http://www.facebook.com. How can I accomplish this. Here is what I have so far

 <StackLayout Padding="50">



  <Image Source="facebook.png" HeightRequest="80"  WidthRequest="80"  >
    <Button Text="Mission" Clicked="Mission_Clicked"></Button>
    <Button Text="Continue" Clicked="Continue_Clicked"></Button>

</StackLayout>

On the click of Facebook, I just want the Facebook page to be displayed on the phones.

Any help will be appreciated.

2

2 Answers

5
votes

Button already has an Image property

<Button Clicked="FacebookClicked" Image="facebook.png" HeightRequest="80"  WidthRequest="80" />

UPDATE Xamarin.Forms 3.4.0

ImageButton:

The ImageButton view combines the Button view and Image view to create a button whose content is an image.

<ImageButton Source="xamagon.png" 
            BackgroundColor="Transparent"
            WidthRequest="300"
            HeightRequest="300"
            FlexLayout.AlignSelf="Center"
            FlexLayout.Grow="1"
            Clicked="ImageButton_Clicked"
            Aspect="AspectFit">
</ImageButton>
1
votes

Try to place an image instead of button. You can make use of Tap Gesture Gesture Recognizer to take click events. Try something like this :