Esempio n. 1
0
        public static Binding TryBinding(
            DependencyObject source, string sourcePropertyPath,
            DependencyObject target, DependencyProperty targetProperty,
            BindingMode mode = BindingMode.TwoWay,
            UpdateSourceTrigger sourceTrigger = UpdateSourceTrigger.Default,
            IValueConverter converter         = null,
            object fallbackValue = null)
        {
            var sourceProperty = source.FindDependencyProperty(sourcePropertyPath);

            if (sourceProperty != null)
            {
                if (source.GetValue(sourceProperty) == null &&
                    sourceProperty.PropertyType == targetProperty.PropertyType)
                {
                    source.SetValue(sourceProperty, target.GetValue(targetProperty));
                }

                return(BindingHelper.SetBinding(
                           source, sourceProperty,
                           target, targetProperty,
                           mode, sourceTrigger, converter, fallbackValue));
            }

            return(null);
        }
Esempio n. 2
0
 public static Binding SetBinding(
     DependencyObject source, DependencyProperty sourceProperty,
     DependencyObject target, DependencyProperty targetProperty,
     BindingMode mode = BindingMode.TwoWay,
     UpdateSourceTrigger sourceTrigger = UpdateSourceTrigger.Default,
     IValueConverter converter         = null,
     object fallbackValue = null)
 {
     return(BindingHelper.SetBinding(
                source, sourceProperty.Name,
                target, targetProperty,
                mode,
                sourceTrigger,
                converter,
                fallbackValue));
 }
Esempio n. 3
0
        public static Binding TryBinding(
            DependencyObject source, DependencyProperty sourceProperty,
            DependencyObject target, string targetPropertyPath,
            BindingMode mode = BindingMode.TwoWay,
            UpdateSourceTrigger sourceTrigger = UpdateSourceTrigger.Default,
            IValueConverter converter         = null,
            object fallbackValue = null)
        {
            var targetProperty = target.FindDependencyProperty(targetPropertyPath);

            if (targetProperty != null)
            {
                return(BindingHelper.SetBinding(
                           source, sourceProperty,
                           target, targetProperty,
                           mode, sourceTrigger, converter, fallbackValue));
            }

            return(null);
        }