private static void RemoveParentIfExists(SidebarElement element) { if (!(element.Parent is StackPanel parent)) { return; } parent.Children.Remove((UIElement)element); }
public SidebarElement PopElement() { StackPanel child1 = this.mMainStackPanel.Children[this.NumColumns - 1] as StackPanel; SidebarElement child2 = child1.Children[child1.Children.Count - 1] as SidebarElement; child1.Children.Remove((UIElement)child2); if (child1.Children.Count == 0) { this.mMainStackPanel.Children.Remove((UIElement)child1); } return(child2); }
void IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.mSidebarElement = (SidebarElement)target; this.mSidebarElement.MouseEnter += new MouseEventHandler(this.SidebarElement_MouseEnter); this.mSidebarElement.MouseLeave += new MouseEventHandler(this.SidebarElement_MouseLeave); this.mSidebarElement.PreviewMouseDown += new MouseButtonEventHandler(this.SidebarElement_PreviewMouseDown); this.mSidebarElement.PreviewMouseUp += new MouseButtonEventHandler(this.SidebarElement_PreviewMouseUp); this.mSidebarElement.Loaded += new RoutedEventHandler(this.SidebarElement_Loaded); this.mSidebarElement.IsEnabledChanged += new DependencyPropertyChangedEventHandler(this.SidebarElement_IsEnabledChanged); break; case 2: this.mBorder = (Border)target; break; case 3: this.mGrid = (Grid)target; break; case 4: this.mImage = (CustomPictureBox)target; this.mImage.Loaded += new RoutedEventHandler(this.MImage_Loaded); break; case 5: this.mElementNotification = (Ellipse)target; break; default: this._contentLoaded = true; break; } }
public void AddElement(SidebarElement element) { if (element == null) { return; } SidebarPopup.RemoveParentIfExists(element); if (this.NumColumns == 0) { this.AddToNewPanel(element); } else { StackPanel child = this.mMainStackPanel.Children[this.NumColumns - 1] as StackPanel; if (child.Children.Count == 3) { this.AddToNewPanel(element); } else { child.Children.Add((UIElement)element); } } }
private void AddToNewPanel(SidebarElement element) { this.CreateStackPanel().Children.Add((UIElement)element); }