Exemple #1
0
        public BehaviorCollectionEx(DependencyObject parent)
        {
            this.parent = new WeakReference <DependencyObject>(parent);

            if (parent is FrameworkElement frameworkElement)
            {
                this.weakLoadedEvent   = new LoadedWeakEventListener(frameworkElement, this);
                this.weakUnloadedEvent = new UnloadedWeakEventListener(frameworkElement, this);
            }
        }
Exemple #2
0
        internal void SetParent(DependencyObject target)
        {
            this.DetachAll();

            if (this.parent == null)
            {
                this.parent = new WeakReference <DependencyObject>(target);
            }
            else
            {
                this.parent.SetTarget(target);
            }

            foreach (var behavior in this)
            {
                behavior.Attach(target);
            }

            if (target is FrameworkElement frameworkElement)
            {
                this.weakLoadedEvent   = new LoadedWeakEventListener(frameworkElement, this);
                this.weakUnloadedEvent = new UnloadedWeakEventListener(frameworkElement, this);
            }
        }