Esempio n. 1
0
        public static void BindingProperty(FrameworkElement targetElement,
                                           DependencyProperty targetProperty,
                                           DependencyObject source,
                                           DependencyProperty childObjProperty,
                                           FrameworkElement defaultSource,
                                           DependencyProperty defaultSourceProperty)
        {
            var isDefault       = DependencyObjectUtils.IsDefaultValue(source, childObjProperty);
            var bindingProperty = isDefault ? defaultSourceProperty : childObjProperty;
            var actualSource    = isDefault ? defaultSource : source;

            BindingProperty(targetElement, targetProperty, actualSource, bindingProperty);
        }
Esempio n. 2
0
 public static void BindingPropertyIfNonDefault(FrameworkElement element,
                                                DependencyProperty targetProperty,
                                                DependencyObject source,
                                                DependencyProperty sourceProperty,
                                                BindingMode mode = BindingMode.OneWay)
 {
     if (DependencyObjectUtils.IsDefaultValue(source, sourceProperty))
     {
         var binding = new Binding()
         {
             Path   = new PropertyPath(sourceProperty),
             Source = source,
             Mode   = mode,
         };
         element.SetBinding(targetProperty, binding);
     }
 }
Esempio n. 3
0
 public static void BindingPropertyIfNonDefault(FrameworkElementFactory factory,
                                                DependencyProperty targetProperty,
                                                DependencyObject source,
                                                DependencyProperty sourceProperty,
                                                IValueConverter converter,
                                                BindingMode mode = BindingMode.OneWay)
 {
     if (!DependencyObjectUtils.IsDefaultValue(source, sourceProperty))
     {
         var binding = new Binding()
         {
             Path      = new PropertyPath(sourceProperty),
             Source    = source,
             Mode      = mode,
             Converter = converter,
         };
         factory.SetBinding(targetProperty, binding);
     }
 }