Esempio n. 1
0
        public static Binder <TSource, UITextField> ShouldReturn <TSource>(this Binder <TSource, UITextField> binder, Expression <Func <TSource, ICommand> > property)
            where TSource : class
        {
            // No weak event use since Should return is a delegate with return type but
            // this is not an issue since there is no subscription to the source
            var compiled = property.Compile();

            binder.Target.ShouldReturn += (textField) => {
                var command = compiled(binder.Source);
                if (command?.CanExecute(null) ?? false)
                {
                    command.Execute(null);
                }
                return(false);
            };
            return(binder.Command <EventArgs>(property, nameof(UIButton.TouchUpInside), (b, v) => b.Enabled = v));
        }
Esempio n. 2
0
 public static Binder <TSource, Button> Click <TSource>(this Binder <TSource, Button> binder, Expression <Func <TSource, ICommand> > property)
     where TSource : class
 {
     return(binder.Command <EventArgs>(property, nameof(Button.Click), (b, v) => b.Enabled = v));
 }
Esempio n. 3
0
 public static Binder <TSource, UIButton> TouchUpInside <TSource>(this Binder <TSource, UIButton> binder, Expression <Func <TSource, ICommand> > property)
     where TSource : class
 {
     return(binder.Command <EventArgs>(property, nameof(UIButton.TouchUpInside), (b, v) => b.Enabled = v));
 }