コード例 #1
0
        public override void Apply()
        {
            var bindingDescription = CreateBindingDescription();

            _bindingContextOwner.AddBinding(_target, bindingDescription, ClearBindingKey);
            base.Apply();
        }
コード例 #2
0
        public static void BindLanguage(this IMvxBindingContextOwner owner
                                        , object target
                                        , string targetPropertyName
                                        , string sourceKey
                                        , string sourcePropertyName = null
                                        , string fallbackValue      = null
                                        , string converterName      = null)
        {
            converterName      = converterName ?? LanguageParser.DefaultConverterName;
            sourcePropertyName = sourcePropertyName ?? LanguageParser.DefaultTextSourceName;

            var converter = ValueConverterLookup.Find(converterName);

            var bindingDescription = new MvxBindingDescription
            {
                TargetName         = targetPropertyName,
                SourcePropertyPath = sourcePropertyName,
                Converter          = converter,
                ConverterParameter = sourceKey,
                FallbackValue      = fallbackValue,
                Mode = MvxBindingMode.OneWay
            };

            owner.AddBinding(target, bindingDescription);
        }
コード例 #3
0
        /// <summary>
        /// Binds the language font.
        /// </summary>
        /// <param name="owner">Owner.</param>
        /// <param name="target">Target.</param>
        /// <param name="languageId">Language identifier.</param>
        /// <param name="fontId">Font identifier.</param>
        public static void BindLanguageFont(this IMvxBindingContextOwner owner
                                            , object target
                                            , string languageId
                                            , string fontId
                                            , string targetPropertyName = null)
        {
            var converter = MvvmCross.Base.MvxSingleton <IMvxBindingSingletonCache> .Instance.ValueConverterLookup.Find("FontLang");

            var bindingDescription = new MvxBindingDescription();

            if (!string.IsNullOrEmpty(targetPropertyName))
            {
                bindingDescription.TargetName = targetPropertyName;
            }
            else
            {
                bindingDescription.TargetName = "AttributedText";
            }

            bindingDescription.Source = new MvxPathSourceStepDescription {
                SourcePropertyPath = "TextSource",
                Converter          = converter,
                ConverterParameter = $"{languageId};{fontId}"
            };

            bindingDescription.Mode = MvxBindingMode.OneTime;
            owner.AddBinding(target, bindingDescription);
        }
コード例 #4
0
        public static void AddLinqBinding <TViewModel, TProperty>(
            this IMvxBindingContextOwner owner,
            TViewModel viewModel,
            Expression <Func <TViewModel, TProperty> > propertyExpression,
            Action <TProperty> action) where TViewModel : INotifyPropertyChanged
        {
            var propertyInfo = GetPropertyInfoFromExpression <TViewModel, TProperty>(propertyExpression);
            var binding      = new LinqBinding <TViewModel, TProperty>(viewModel, propertyInfo, action);

            owner.AddBinding(owner, binding);
        }
コード例 #5
0
        public static void AddBindings(this IMvxBindingContextOwner view, IEnumerable <IMvxUpdateableBinding> bindings)
        {
            if (bindings == null)
            {
                return;
            }

            foreach (var binding in bindings)
            {
                view.AddBinding(binding);
            }
        }
コード例 #6
0
        public static void AddBindings(this IMvxBindingContextOwner view, object target, IEnumerable <IMvxUpdateableBinding> bindings, object clearKey = null)
        {
            if (bindings == null)
            {
                return;
            }

            foreach (var binding in bindings)
            {
                view.AddBinding(target, binding, clearKey);
            }
        }
コード例 #7
0
        private static void Bind(this IMvxBindingContextOwner bindingOwner, object target, IMvxValueConverter converter,
                                 object converterParameter, object fallbackValue, MvxBindingMode mode,
                                 string parsedTargetPath, string parsedSourcePath)
        {
            var description = new MvxBindingDescription
            {
                TargetName         = parsedTargetPath,
                SourcePropertyPath = parsedSourcePath,
                Converter          = converter,
                ConverterParameter = converterParameter,
                FallbackValue      = fallbackValue,
                Mode = mode
            };

            bindingOwner.AddBinding(target, description);
        }
コード例 #8
0
        // add whenever something changes
        public static void AddLinqBinding <TViewModel, TProperty>(
            this IMvxBindingContextOwner owner,
            TViewModel viewModel,
            Expression <Func <TViewModel, TProperty> > propertyExpression,
            Action <TProperty> action) where TViewModel : INotifyPropertyChanged
        {
            //Action createBinding = () =>
            //    {
            var propertyInfo = GetPropertyInfoFromExpression <TViewModel, TProperty>(propertyExpression);
            var binding      = new LinqBinding <TViewModel, TProperty>(viewModel, propertyInfo, action);

            owner.AddBinding(owner, binding);
            //owner.CreateBinding(binding);
            //    };

            //viewModel.PropertyChanged += (sender, args) =>
            //    createBinding();

            //createBinding();
        }
コード例 #9
0
        public static void BindFont(this IMvxBindingContextOwner owner
                                    , object target
                                    , string sourceKey
                                    )
        {
            //lookup the converter
            var converter = MvxBindingSingletonCache.Instance.ValueConverterLookup.Find("FontResource");

            var bindingDescription = new MvxBindingDescription
            {
                TargetName = "Font",
                Source     = new MvxPathSourceStepDescription
                {
                    SourcePropertyPath = "AssetProvider",
                    Converter          = converter,
                    ConverterParameter = sourceKey
                },
                Mode = MvxBindingMode.OneTime
            };

            owner.AddBinding(target, bindingDescription);
        }