Esempio n. 1
0
 /// <summary>Bind to the default property</summary>
 public static TBindable Bind <TBindable>(
     this TBindable bindable,
     string path               = bindingContextPath,
     BindingMode mode          = BindingMode.Default,
     IValueConverter converter = null,
     object converterParameter = null,
     string stringFormat       = null,
     object source             = null,
     object targetNullValue    = null,
     object fallbackValue      = null
     ) where TBindable : BindableObject
 {
     bindable.Bind(
         DefaultBindableProperties.GetFor(bindable),
         path, mode, converter, converterParameter, stringFormat, source, targetNullValue, fallbackValue
         );
     return(bindable);
 }
Esempio n. 2
0
        /// <summary>Bind to the <typeparamref name="TBindable"/>'s default Command and CommandParameter properties </summary>
        /// <param name="parameterPath">If null, no binding is created for the CommandParameter property</param>
        public static TBindable BindCommand <TBindable>(
            this TBindable bindable,

            string path            = bindingContextPath,
            object source          = null,
            string parameterPath   = bindingContextPath,
            object parameterSource = null
            ) where TBindable : BindableObject
        {
            VerifyExperimental();
            (var commandProperty, var parameterProperty) = DefaultBindableProperties.GetForCommand(bindable);

            bindable.SetBinding(commandProperty, new Binding(path: path, source: source));

            if (parameterPath != null)
            {
                bindable.SetBinding(parameterProperty, new Binding(path: parameterPath, source: parameterSource));
            }

            return(bindable);
        }
Esempio n. 3
0
        /// <summary>Bind to the default property with inline conversion and conversion parameter</summary>
        public static TBindable Bind <TBindable, TSource, TParam, TDest>(
            this TBindable bindable,
            string path      = bindingContextPath,
            BindingMode mode = BindingMode.Default,
            Func <TSource, TParam, TDest> convert     = null,
            Func <TDest, TParam, TSource> convertBack = null,
            object converterParameter = null,
            string stringFormat       = null,
            object source             = null,
            object targetNullValue    = null,
            object fallbackValue      = null
            ) where TBindable : BindableObject
        {
            VerifyExperimental();
            var converter = new FuncConverter <TSource, TDest, TParam>(convert, convertBack);

            bindable.Bind(
                DefaultBindableProperties.GetFor(bindable),
                path, mode, converter, converterParameter, stringFormat, source, targetNullValue, fallbackValue
                );
            return(bindable);
        }