How To Create Bindable TouchAction For Effect

heart2friendheart2friend Member ✭✭

SOURCE CODE:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Input;
using Xamarin.Forms;

namespace Test
{
public class TouchEffect : RoutingEffect
{
public event TouchActionEventHandler TouchAction;

    public TouchEffect() : base("Test.TouchEffect")
    {
    }

    public bool Capture { set; get; }

    public async void OnTouchAction(Element element, TouchActionEventArgs args)
    {
        TouchAction?.Invoke(element, args);
    }       
}

}

XAML:

<ContentPage.Effects>

</ContentPage.Effects>

effect shows TouchAction event handler how to convert it into bindable event so that we can use it like below

<ContentPage.Effects>

</ContentPage.Effects>

Answers

  • LucasZhangLucasZhang Member, Xamarin Team Xamurai

    Did you want to handle it in MVVM?

  • heart2friendheart2friend Member ✭✭

    Yes

  • LucasZhangLucasZhang Member, Xamarin Team Xamurai

    Why not to use tap gesture recognizer?

  • heart2friendheart2friend Member ✭✭
    edited May 17

    I tried with TapGesture also but its not giving expected output

  • LucasZhangLucasZhang Member, Xamarin Team Xamurai
    edited May 17

    Though you get expected output,Why not use it?

Sign In or Register to comment.