The "Image Source="icons.png"" works fine but when i insert this code: "Button Image="icons.png"" the app wont display in the xamarin live
This is my code:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Project.CustomImages">
<StackLayout>
<Button Image="icons.png"/>
<Label Text="TEST"/>
<Image Source="icons.png"/>
</StackLayout>
</ContentPage>
This is the screen shot for my folders(drawable): Screenshot
Try to place an image instead of button.
You can make use of Tap Gesture Recogniser to take click events.
Try something like this :
<Image Source="icons.jpg">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="OnTapped" />
</Image.GestureRecognizers>
</Image>
The code for the event handler
void OnTapped(object sender, EventArgs args) {
// Do something
DisplayAlert ("Alert", "Image Button Clicked", "OK");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.