private ItemsControl GetItemsControlContainingPanel(PanelControl panel) { if (this.IsPanelInItemsControl(panel, this.LeftPanelContainer)) { return this.LeftPanelContainer; } else if (this.IsPanelInItemsControl(panel, this.RightPanelContainer)) { return this.RightPanelContainer; } else { return null; } }
private void OnDragPanel(object o, RoutedEventArgs args) { panel = o as PanelControl; knownParent = this.GetItemsControlContainingPanel(panel); if (knownParent != null) { knownParent.Items.Remove(panel); this.DocumentRoot.Children.Add(panel); panel.Width = panel.RenderSize.Width; panel.IsHitTestVisible = false; panel.HorizontalAlignment = HorizontalAlignment.Left; panel.VerticalAlignment = VerticalAlignment.Top; Grid.SetColumnSpan(panel, this.DocumentRoot.ColumnDefinitions.Count); } }
private bool IsPanelInItemsControl(PanelControl panel, ItemsControl itemsControl) { foreach (PanelControl item in itemsControl.Items) { if (item == panel) { return true; } } return false; }