public EventBinder(DXEventExtension owner, Type eventHandlerType, BindingBase binding)
 {
     lock (locker) {
         this.errorHandler = owner.ErrorHandler;
         this.calculator   = owner.Calculator;
         var target = (DependencyObject)owner.TargetProvider.TargetObject;
         this.targetObject     = new WeakReference(target);
         this.eventHandlerType = eventHandlerType;
         var dataPropertyInfo = Tuple.Create(target.GetType(), owner.Handler);
         if (!propertiesCache.TryGetValue(dataPropertyInfo, out dataProperty))
         {
             dataProperty = DependencyProperty.Register(
                 "Tag" + dataPropertyIndex++.ToString(), typeof(object), dataPropertyInfo.Item1);
             propertiesCache[dataPropertyInfo] = dataProperty;
         }
         try {
             BindingOperations.SetBinding(target, dataProperty, binding);
         } catch (Exception e) {
             string message = "DXEvent cannot set binding on data property. " + Environment.NewLine
                              + "Expr: " + owner.Handler + Environment.NewLine
                              + "TargetProperty: " + owner.TargetPropertyName + Environment.NewLine
                              + "TargetPropertyType: " + owner.TargetPropertyType.ToString() + Environment.NewLine
                              + "TargetObjectType: " + target.GetType() + Environment.NewLine
                              + "DataProperty: " + dataProperty.Name;
             throw new DXEventException(owner, message, e);
         }
     }
 }
Ejemplo n.º 2
0
            public EventBinder(DXEventExtension owner, Type eventHandlerType, BindingBase binding)
            {
                this.errorHandler = owner.ErrorHandler;
                this.calculator   = owner.Calculator;
                var target = (DependencyObject)owner.TargetProvider.TargetObject;

                this.targetObject     = new WeakReference(target);
                this.eventHandlerType = eventHandlerType;
                dataProperty          = DependencyProperty.RegisterAttached(
                    owner.TargetPropertyName + Guid.NewGuid().ToString(), typeof(object), typeof(EventBinder), null);
                BindingOperations.SetBinding(target, dataProperty, binding);
            }
Ejemplo n.º 3
0
 public EventConverter(DXEventExtension owner, bool isEmpty) : base(owner)
 {
     this.isEmpty = isEmpty;
 }