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); } }
private static void OnAppareanceElementChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { ResizeBehavior source = (ResizeBehavior)obj; if (source.AssociatedObject == null) { return; } source.setRectangle(source.resizePart); }
private static void StayInParentPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { ResizeBehavior source = (ResizeBehavior)obj; source.checkParentBounds(); }
private static void OnSizeChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { ResizeBehavior source = (ResizeBehavior)obj; source.checkSizeValues(); }