Ffimageloading: Svg image and event handler?

Created on 12 Jul 2017  路  4Comments  路  Source: luberda-molinet/FFImageLoading

Is there a way to detect clicks/taps on a image?

/Oliver

Xamarin.Forms question

Most helpful comment

This is working for me:

<?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="App.Views.MainPage"
     xmlns:image="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms">
    <ContentPage.Content>
        <image:CachedImage Aspect="AspectFill" HeightRequest="200"
            WidthRequest="200" Source="usericon200.png"
            DownsampleToViewSize="true" HorizontalOptions="Center"
            VerticalOptions="Start" x:Name="ProfileImage">
            <image:CachedImage.GestureRecognizers>
                <TapGestureRecognizer Tapped="ActivateDebugMode"
                     NumberOfTapsRequired="7" />
            </image:CachedImage.GestureRecognizers>
        </image:CachedImage>
        <Image Source="settings50.png" VerticalOptions="Center"
            TranslationX="80" TranslationY="-50"
            HorizontalOptions="Center" WidthRequest="40">
            <Image.GestureRecognizers>
                <TapGestureRecognizer Tapped="OpenSettings" NumberOfTapsRequired="1" />
            </Image.GestureRecognizers>
        </Image>
    </ContentPage.Content>
</ContentPage>

All 4 comments

SkiaSharp has this which FFImageLoading is based on, you can see some examples of it here:

https://github.com/xamarin/xamarin-forms-samples/tree/master/SkiaSharpForms/SkiaSharpFormsDemos

If you're using SvgCachedImage, you can just add a GestureRecognizer as in any other Xamarin.Forms view: https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/gestures/tap/

This is working for me:

<?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="App.Views.MainPage"
     xmlns:image="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms">
    <ContentPage.Content>
        <image:CachedImage Aspect="AspectFill" HeightRequest="200"
            WidthRequest="200" Source="usericon200.png"
            DownsampleToViewSize="true" HorizontalOptions="Center"
            VerticalOptions="Start" x:Name="ProfileImage">
            <image:CachedImage.GestureRecognizers>
                <TapGestureRecognizer Tapped="ActivateDebugMode"
                     NumberOfTapsRequired="7" />
            </image:CachedImage.GestureRecognizers>
        </image:CachedImage>
        <Image Source="settings50.png" VerticalOptions="Center"
            TranslationX="80" TranslationY="-50"
            HorizontalOptions="Center" WidthRequest="40">
            <Image.GestureRecognizers>
                <TapGestureRecognizer Tapped="OpenSettings" NumberOfTapsRequired="1" />
            </Image.GestureRecognizers>
        </Image>
    </ContentPage.Content>
</ContentPage>

Is there any way to add custom gesture recognizer? Before applying FFImageLoading I had custom ImageRenderer. Is there any way to "subscribe" or override CachedImage OnTouch event?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CNDOGTA picture CNDOGTA  路  3Comments

jdbrock picture jdbrock  路  4Comments

PostImpatica picture PostImpatica  路  4Comments

angelru picture angelru  路  4Comments

JeremyBP picture JeremyBP  路  5Comments