How can I create an image button in Xamarin.Forms?
2 answers
Many ways, like this one:
var button = new Image { ... }; // make your image your button should be
button.GestureRecognizers.Add (new TapGestureRecognizer (sender => {
// Do whatever you want to do when its tapped
button.Opacity = 0.6;
button.FadeTo (1);
}));
Or you can even use Xamarin forms labs:
https://github.com/XLabs/Xamarin-Forms-Labs
Or like @Gerald Versluis say:
With an image of a button property.
Image="logo.jpg"
+7
source to share
Actually
Xamarin.Forms.TapGestureRecognizer.TapGestureRecognizer (System.Action)
deprecated: "Deprecated in 1.0.2. Use the command instead
Try this one:
var CallButton = new Image { Source = "call.png" };
CallButton.GestureRecognizers.Add(new TapGestureRecognizer
{
Command=new Command(()=> {
// Do whatever you want to do when its tapped
})
});
For more information, check the following link:
http://www.c-sharpcorner.com/UploadFile/e04e9a/xamarin-forms-image-button-recipe/
+1
source to share