#pragma warning restore SA1202 // Elements must be ordered by access

        private static void OnTrackChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            d.SetValue(EventsPropertyKey, new ObservableCollection <object>());
            _ = d.Bind(HasErrorProperty)
                .OneWayTo(d, Scope.HasErrorProperty);
            _ = d.Bind(ErrorsProperty)
                .OneWayTo(d, Scope.ErrorsProperty);
            Scope.AddErrorHandler(d, (o, args) => GetEvents((DependencyObject)o).Add(args));
        }
        //...

        public static BindingExpressionBase MultiBind(this DependencyObject input, DependencyProperty property, IMultiValueConverter converter, params Binding[] bindings)
        {
            var result = new MultiBinding()
            {
                Converter = converter,
                Mode      = BindingMode.OneWay,
            };

            if (bindings?.Length > 0)
            {
                bindings.ForEach(i => result.Bindings.Add(i));
            }

            return(input.Bind(property, result));
        }
        private static void OnElementChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (e.NewValue == null)
            {
                BindingOperations.ClearBinding(d, DataContextProperty);
                BindingOperations.ClearBinding(d, HasErrorProxyProperty);
                BindingOperations.ClearBinding(d, ErrorsProxyProperty);
                BindingOperations.ClearBinding(d, NodeProxyProperty);
            }
            else
            {
                d.Bind(DataContextProperty)
                .OneWayTo(e.NewValue, DataContextProperty);

                d.Bind(HasErrorProxyProperty)
                .OneWayTo(e.NewValue, Scope.HasErrorProperty);

                d.Bind(ErrorsProxyProperty)
                .OneWayTo(e.NewValue, Scope.ErrorsProperty);

                d.Bind(NodeProxyProperty)
                .OneWayTo(e.NewValue, Scope.NodeProperty);
            }
        }
 public static BindingExpressionBase Bind(this DependencyObject input, DependencyProperty property, string path, object source, BindingMode mode = BindingMode.OneWay, IValueConverter converter = null, object converterParameter = null, UpdateSourceTrigger updateSourceTrigger = UpdateSourceTrigger.PropertyChanged) => input.Bind(property, new PropertyPath(path), source, mode, converter, converterParameter, updateSourceTrigger);
Exemple #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="Value"></param>
 /// <param name="Property"></param>
 /// <param name="Source"></param>
 /// <param name="Path"></param>
 /// <param name="Converter"></param>
 /// <param name="ConverterParameter"></param>
 /// <param name="Mode"></param>
 /// <param name="UpdateSourceTrigger"></param>
 /// <returns></returns>
 public static BindingExpressionBase Bind(this DependencyObject Value, DependencyProperty Property, object Source, string Path, IValueConverter Converter, object ConverterParameter = null, BindingMode Mode = BindingMode.TwoWay, UpdateSourceTrigger UpdateSourceTrigger = UpdateSourceTrigger.Default)
 {
     return(Value.Bind(Property, Source, new PropertyPath(Path), Converter, ConverterParameter, Mode, UpdateSourceTrigger));
 }
Exemple #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="Value"></param>
 /// <param name="Property"></param>
 /// <param name="Source"></param>
 /// <param name="Path"></param>
 /// <param name="Mode"></param>
 /// <returns></returns>
 public static BindingExpressionBase Bind(this DependencyObject Value, DependencyProperty Property, object Source, PropertyPath Path, BindingMode Mode = BindingMode.TwoWay, UpdateSourceTrigger UpdateSourceTrigger = UpdateSourceTrigger.Default)
 {
     return(Value.Bind(Property, Source, new PropertyPath(Path), null, null, Mode, UpdateSourceTrigger));
 }