Exemplo n.º 1
0
        /// <summary>Destinations the specified get target.</summary>
        /// <typeparam name="TTarget">The type of the target.</typeparam>
        /// <typeparam name="TValue">The type of the target value.</typeparam>
        /// <param name="id">The id.</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="setSourceValue">The set source value.</param>
        /// <param name="bindingMode">The binding mode.</param>
        /// <param name="updateSourceTrigger">The update source trigger.</param>
        /// <returns>A new destination.</returns>
        public DataBinding <TRoot, TSource, TTarget, TValue> BindInvariant <TTarget, TValue>(
            int id,
            TTarget target,
            INotifyingProperty <TSource> sourceProperty,
            Func <TSource, TValue> getSourceValue,
            DependencyProperty targetProperty,
            Func <TTarget, TValue> getTargetValue,
            Action <TSource, TValue> setSourceValue,
            BindingMode bindingMode,
            UpdateSourceTrigger updateSourceTrigger = UpdateSourceTrigger.Default)
            where TTarget : DependencyObject
        {
            var dataDestination = new DataBinding <TRoot, TSource, TTarget, TValue>(
                id,
                this,
                target,
                sourceProperty,
                getSourceValue,
                targetProperty,
                getTargetValue,
                setSourceValue,
                updateSourceTrigger,
                bindingMode);

            this.bindings.Add(dataDestination);
            return(dataDestination);
        }
Exemplo n.º 2
0
 /// <summary>Initializes a new instance of the <see cref="PathPart{TRoot, TParentSource, TSource}"/> class.</summary>
 /// <param name="bindingContext">The data context.</param>
 /// <param name="sourceProperty">The source property.</param>
 /// <param name="getSource">The get source.</param>
 /// <param name="bindingMode">The binding mode.</param>
 public PathPart(IBindingContext <TRoot, TParentSource> bindingContext, INotifyingProperty <TParentSource> sourceProperty, Func <TParentSource, TSource> getSource, BindingMode bindingMode)
 {
     this.bindingContext = bindingContext;
     this.sourceProperty = sourceProperty;
     this.getSource      = getSource;
     this.bindingMode    = bindingMode;
     this.sourceProperty.Initialize(this);
 }
Exemplo n.º 3
0
        /// <summary>Binds the specified source property.</summary>
        /// <typeparam name="TNewSource">The type of the new source.</typeparam>
        /// <param name="sourceProperty">The source property.</param>
        /// <param name="getSourcePart">The get source.</param>
        /// <param name="bindingMode">The binding mode.</param>
        /// <returns>A path part.</returns>
        public PathPart <TRoot, TSource, TNewSource> BindPart <TNewSource>(
            INotifyingProperty <TSource> sourceProperty,
            Func <TSource, TNewSource> getSourcePart,
            BindingMode bindingMode)
        {
            var pathPart = new PathPart <TRoot, TSource, TNewSource>(this, sourceProperty, getSourcePart, bindingMode);

            this.bindings.Add(pathPart);
            return(pathPart);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        /// <summary>Destinations the specified get target.</summary>
        /// <typeparam name="TTarget">The type of the target.</typeparam>
        /// <typeparam name="TValue">The type of the target value.</typeparam>
        /// <param name="id">The id.</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.</param>
        /// <returns>A new destination.</returns>
        public DataBindingOneWay <TRoot, TSource, TTarget, TValue> BindInvariantOneWay <TTarget, TValue>(
            int id,
            TTarget target,
            INotifyingProperty <TSource> sourceProperty,
            Func <TSource, TValue> getSourceValue,
            DependencyProperty targetProperty,
            Func <TTarget, TValue> getTargetValue,
            BindingMode bindingMode)
            where TTarget : DependencyObject
        {
            var dataDestination = new DataBindingOneWay <TRoot, TSource, TTarget, TValue>(
                id,
                this,
                target,
                sourceProperty,
                getSourceValue,
                targetProperty,
                getTargetValue,
                bindingMode);

            this.bindings.Add(dataDestination);
            return(dataDestination);
        }
        /// <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);
        }