Example #1
0
        void AssociatedObject_Loaded(object sender, RoutedEventArgs e)
        {
            this.AssociatedObject.Loaded -= new RoutedEventHandler(AssociatedObject_Loaded);

            BehaviorCollection parent_attached_behaviors = Interaction.GetBehaviors(this.AssociatedObject.Parent);

            ResizeBehavior parent_resize_behavior = null;

            foreach (Behavior b in parent_attached_behaviors)
            {
                if (b.GetType() == typeof(ResizeBehavior))
                {
                    parent_resize_behavior = (ResizeBehavior)b;
                    break;
                }
            }

            if (parent_resize_behavior == null)
            {
                (this.AssociatedObject.Parent as FrameworkElement).SizeChanged += new SizeChangedEventHandler(ParentSizeChanged);
            }

            else
            {
                //attach to parent's resize behavior to notice size changes
                parent_resize_behavior.SizeChanged += new EventHandler(ParentBehaviorSizeChanged);
            }
        }
Example #2
0
        private static void OnAppareanceElementChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            ResizeBehavior source = (ResizeBehavior)obj;

            if (source.AssociatedObject == null)
            {
                return;
            }

            source.setRectangle(source.resizePart);
        }
Example #3
0
        private static void StayInParentPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            ResizeBehavior source = (ResizeBehavior)obj;

            source.checkParentBounds();
        }
Example #4
0
        private static void OnSizeChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            ResizeBehavior source = (ResizeBehavior)obj;

            source.checkSizeValues();
        }