如何在Xamarin.Forms中创建图像按钮?

如何在Xamarin.Forms中创建图像按钮?,xamarin,xamarin.forms,xamarin.mac,Xamarin,Xamarin.forms,Xamarin.mac,请让我们知道如何在Xamarin.Forms中创建图像按钮,我们不使用故事板 环境:Mac上的Xamarin Studio有很多种方式,比如: var button = new Image { ... }; // make your image your button should be button.GestureRecognizers.Add (new TapGestureRecognizer (sender => { // Do whatever you want to do w

请让我们知道如何在Xamarin.Forms中创建图像按钮,我们不使用故事板


环境:Mac上的Xamarin Studio有很多种方式,比如:

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);
}));
  var CallButton = new Image { Source = "call.png" };
      CallButton.GestureRecognizers.Add(new TapGestureRecognizer
             {
              Command=new Command(()=> {
                // Do whatever you want to do when its tapped
                  })
              });
或者您甚至可以使用Xamarin forms labs:

或者像@Gerald Versluis说的:

具有按钮的图像属性

Image="logo.jpg"
实际上

Xamarin.Forms.TapGestureRecognizer.TapGestureRecognizer(System.Action)

已过时:“在1.0.2中已过时。改用命令

试试这个:

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);
}));
  var CallButton = new Image { Source = "call.png" };
      CallButton.GestureRecognizers.Add(new TapGestureRecognizer
             {
              Command=new Command(()=> {
                // Do whatever you want to do when its tapped
                  })
              });
有关详细信息,请查看以下链接:


在xamrin表单中,按钮具有图像属性。您可以这样设置。。。使用按钮的image属性,文本位于图像旁边。如何在图像上生成文本。是否可以在xaml中执行此操作?@user1027076..检查此解决方案