Пример #1
0
        /// <summary>Initializes a new instance of the <see cref="DataBinding{TRoot, TSource,TSourceValue,TTarget,TTargetValue}"/> class.</summary>
        /// <param name="id">The id.</param>
        /// <param name="bindingContext">The data context.</param>
        /// <param name="target">The target.</param>
        /// <param name="sourceProperty">The source property.</param>
        /// <param name="getSourceValue">The get source value.</param>
        /// <param name="targetProperty">The target property.</param>
        /// <param name="getTargetValue">The get target value.</param>
        /// <param name="setSource">The set source.</param>
        /// <param name="updateSourceTrigger">The update source trigger value.</param>
        /// <param name="bindingMode">The binding mode value.</param>
        public DataBinding(
            int id,
            IBindingContext <TRoot, TSource> bindingContext,
            TTarget target,
            INotifyingProperty <TSource> sourceProperty,
            Func <TSource, TSourceValue> getSourceValue,
            DependencyProperty targetProperty,
            Func <TTarget, TTargetValue> getTargetValue,
            Action <TSource, TSourceValue> setSource,
            UpdateSourceTrigger updateSourceTrigger,
            BindingMode bindingMode)
        {
            this.sourceProperty = sourceProperty;
            this.setSource      = setSource;
            DataBindingHelper.GetNotificationParameters(target, targetProperty, ref bindingMode, ref updateSourceTrigger);
            DataBindingHelper.TryRegisterLostFocus(target, updateSourceTrigger, this.OnTargetLostFocus);
            var conversionParameters = ConversionProvider.GetConversionParameters <TSourceValue, TTargetValue>(target, id, bindingMode);

            this.dataBindingState = new DataBindingState <TRoot, TSource, TSourceValue, TTarget, TTargetValue>(bindingContext, target, targetProperty, getTargetValue, getSourceValue, bindingMode, updateSourceTrigger, conversionParameters);
            this.sourceProperty.Initialize(this);
        }
        /// <summary>Initializes a new instance of the <see cref="DataBindingOneWay{TRoot,TSource,TTarget,TValue}"/> class.</summary>
        /// <param name="id">The id.</param>
        /// <param name="bindingContext">The data context.</param>
        /// <param name="target">The  target.</param>
        /// <param name="sourceProperty">The source property.</param>
        /// <param name="getSourceValue">The get source value.</param>
        /// <param name="targetProperty">The target property.</param>
        /// <param name="getTargetValue">The get target value.</param>
        /// <param name="bindingMode">The binding mode value.</param>
        public DataBindingOneWay(
            int id,
            IBindingContext <TRoot, TSource> bindingContext,
            TTarget target,
            INotifyingProperty <TSource> sourceProperty,
            Func <TSource, TValue> getSourceValue,
            DependencyProperty targetProperty,
            Func <TTarget, TValue> getTargetValue,
            BindingMode bindingMode)
        {
            this.sourceProperty = sourceProperty;
            var conversionParameters = ConversionProvider.GetConversionParameters <TValue, TValue>(target, id);

            this.dataBindingState = new DataBindingState <TRoot, TSource, TValue, TTarget, TValue>(
                bindingContext,
                target,
                targetProperty,
                getTargetValue,
                getSourceValue,
                bindingMode,
                UpdateSourceTrigger.Explicit,
                conversionParameters);
            this.sourceProperty.Initialize(this);
        }