private void DoLayout() { List <ITopLevelWindow> windows = new List <ITopLevelWindow>(); foreach (UIElement entry in this.entries) { ITopLevelWindow window = VisualTreeHelper.GetTopLevelWindow(entry); if (window != null && !windows.Contains(window)) { windows.Add(window); } } foreach (ITopLevelWindow window in windows) { window.DoLayoutPass(); } this.entries.Clear(); this.layoutPassQueued = false; }