private static void SetupParticipatingLayouts(DockItem dockItem) { var sourceOfdockItemsControl = dockItem.GetSelfAndLogicalAncestors().OfType <ItemsControl>().FirstOrDefault() as DockItemsControl; if (sourceOfdockItemsControl == null || (sourceOfdockItemsControl.Items as ICollection).Count != 1) { return; } var draggingWindow = dockItem.GetSelfAndVisualAncestors().OfType <Window>().First(); if (draggingWindow == null) { return; } foreach (var loadedLayout in LoadedLayouts.Where(l => l.Partition == dockItem.PartitionAtDragStart && !Equals(l.GetSelfAndVisualAncestors().OfType <Window>().FirstOrDefault(), draggingWindow))) { loadedLayout.IsParticipatingInDrag = true; } }