Ejemplo n.º 1
0
 public static IDisposable BindCommand <TView, TViewModel, TProp>(
     this TView view,
     TViewModel viewModel,
     Expression <Func <TViewModel, TProp> > propertyName,
     string toEvent = null)
     where TViewModel : class
     where TView : class, IViewFor <TViewModel>
     where TProp : ICommand
 {
     return(binderImplementation.BindCommand(viewModel, view, propertyName, toEvent));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Bind a command from the ViewModel to an explicitly specified control
 /// on the View.
 /// </summary>
 /// <typeparam name="TView">The view type.</typeparam>
 /// <typeparam name="TViewModel">The view model type.</typeparam>
 /// <typeparam name="TProp">The property type.</typeparam>
 /// <typeparam name="TControl">The control type.</typeparam>
 /// <typeparam name="TParam">The parameter type.</typeparam>
 /// <returns>A class representing the binding. Dispose it to disconnect
 /// the binding.</returns>
 /// <param name="view">The View.</param>
 /// <param name="viewModel">The View model.</param>
 /// <param name="propertyName">The ViewModel command to bind.</param>
 /// <param name="controlName">The name of the control on the view.</param>
 /// <param name="withParameter">The ViewModel property to pass as the
 /// param of the ICommand.</param>
 /// <param name="toEvent">If specified, bind to the specific event
 /// instead of the default.
 /// NOTE: If this parameter is used inside WhenActivated, it's
 /// important to dispose the binding when the view is deactivated.</param>
 public static IReactiveBinding <TView, TProp> BindCommand <TView, TViewModel, TProp, TControl, TParam>(
     this TView view,
     TViewModel viewModel,
     Expression <Func <TViewModel, TProp> > propertyName,
     Expression <Func <TView, TControl> > controlName,
     IObservable <TParam> withParameter,
     string?toEvent = null)
     where TViewModel : class
     where TView : class, IViewFor <TViewModel>
     where TProp : ICommand =>
 _binderImplementation.BindCommand(viewModel, view, propertyName, controlName, withParameter, toEvent);
 public static IReactiveBinding <TView, TProp> BindCommand <TView, TViewModel, TProp, TControl>(
     this ICommandBinderImplementation @this,
     TViewModel viewModel,
     TView view,
     Expression <Func <TViewModel, TProp> > propertyName,
     Expression <Func <TView, TControl> > controlName,
     string?toEvent = null)
     where TViewModel : class
     where TView : class, IViewFor <TViewModel>
     where TProp : ICommand =>
 @this.BindCommand(viewModel, view, propertyName, controlName, Observable <object> .Empty, toEvent);
Ejemplo n.º 4
0
 public static IDisposable BindCommand <TView, TViewModel, TProp, TControl>(
     this ICommandBinderImplementation This,
     TViewModel viewModel,
     TView view,
     Expression <Func <TViewModel, TProp> > propertyName,
     Expression <Func <TView, TControl> > controlName,
     string toEvent = null)
     where TViewModel : class
     where TView : class, IViewFor <TViewModel>
     where TProp : ICommand
 {
     return(This.BindCommand(viewModel, view, propertyName, controlName, Observable.Empty <object>(), toEvent));
 }
Ejemplo n.º 5
0
 public static IDisposable BindCommand <TView, TViewModel, TProp, TControl, TParam>(
     this ICommandBinderImplementation This,
     TViewModel viewModel,
     TView view,
     Expression <Func <TViewModel, TProp> > propertyName,
     Expression <Func <TView, TControl> > controlName,
     Expression <Func <TViewModel, TParam> > withParameter,
     string toEvent = null)
     where TViewModel : class
     where TView : class, IViewFor <TViewModel>
     where TProp : ICommand
 {
     return(This.BindCommand(viewModel, view, propertyName, controlName, view.ViewModel.WhenAny(withParameter, x => x.Value), toEvent));
 }
Ejemplo n.º 6
0
        public static IReactiveBinding <TView, TViewModel, TProp> BindCommand <TView, TViewModel, TProp, TControl, TParam>(
            this ICommandBinderImplementation This,
            TViewModel viewModel,
            TView view,
            Expression <Func <TViewModel, TProp> > propertyName,
            Expression <Func <TView, TControl> > controlName,
            Expression <Func <TViewModel, TParam> > withParameter,
            string toEvent = null)
            where TViewModel : class
            where TView : class, IViewFor <TViewModel>
            where TProp : ICommand
        {
            var paramExpression = Reflection.Rewrite(withParameter.Body);
            var param           = Reflection.ViewModelWhenAnyValue(viewModel, view, paramExpression);

            return(This.BindCommand(viewModel, view, propertyName, controlName, param, toEvent));
        }