0

How to create custom bindings for Windows Phone?

I need to do something like this (but this example for Android): answer

Custom bindings in Android:

public class LongClickEventBinding
    : MvxBaseAndroidTargetBinding
{
    private readonly View _view;
    private IMvxCommand _command;

    public LongPressEventBinding(View view)
    {
        _view = view;
        _view.LongClick += ViewOnLongClick;
    }

    private void ViewOnLongClick(object sender, View.LongClickEventArgs eventArgs)
    {
        if (_command != null)
        {
            _command.Execute();
        }
    }

    public override void SetValue(object value)
    {
        _command = (IMvxCommand)value;
    }

    protected override void Dispose(bool isDisposing)
    {
        if (isDisposing)
        {
            _view.Click -= ViewOnLongClick;
        }
        base.Dispose(isDisposing);
    }

    public override Type TargetType
    {
        get { return typeof(IMvxCommand); }
    }

    public override MvxBindingMode DefaultMode
    {
        get { return MvxBindingMode.OneWay; }
    }
}

Excuse me for the improper question..

Community
  • 1
  • 1
Andrew Andreev
  • 394
  • 4
  • 13

2 Answers2

0

As far as I understood your question, you don't need to develop anything at all. Use Blend to apply & setup CallMethodAction built-in behavior, and implement public method in your VM class.

Soonts
  • 20,079
  • 9
  • 57
  • 130
0

WP7 doesn't expose Tap and Hold as an event.

However, I believe you can access this sort og thing in Wp7 and Wp8 using Gestures - e.g.

Stuart
  • 66,722
  • 7
  • 114
  • 165