This project has moved and is read-only. For the latest updates, please go here.

child window throwing stackoverflow exception

Jul 14, 2011 at 2:16 PM
Edited Jul 14, 2011 at 2:17 PM

I don't know if anyone has ever faced this problem but the child window is throwing stackoverflow exception in TopProperty dependency property. When I went thru the code i found out that


public double Top
            get { return (double)GetValue(TopProperty); }
            set { SetValue(TopProperty, value); }

        private static void OnTopPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
            ChildWindow window = (ChildWindow)obj;
            window.Top = window.GetRestrictedTop();
            window.ProcessMove(0, (double)e.NewValue - (double)e.OldValue);


the Top property is in infinite loop call.

Rather than checking for the restricted boundary in the dependency property callback, how about setting it else where where you might need to recheck with the restricted boundary before setting the top and left position of the control, such as in ProcessMove()  and HeaderMouseMove() functions.

But I wonder why don't I get the same problem in Left Property :)

Anyway great toolkit. You have saved my day.



Jul 14, 2011 at 2:54 PM

The Top property is not in a infinite loop call.  The GetRestrictedTop simply corrects the Top value only if it needs to be, but the Top property doesn't always change.  So if the Top value was 10 and the method returned 10 the property changed callback would not execute again.  What version are you using?  Can you provide a sample application that replicates this behavior?

Jul 14, 2011 at 4:00 PM

Sorry for wasting your time. I had an old download. Your new code looks clean and clear.

Well I was just trying to implement the behavior so that I can actually open a child window from code behind by supplying a parentcontainer in the parameter and the overloaded show method would automatically add itself into the parentcontainer.

I was also trying to implement a behavior so that the child window would actually open itself in a new window, kinda behaving itself as a real window.

Hope you are working on that.


Thanks anyway.