protected override void OnUnchecked(RoutedEventArgs e) { base.OnUnchecked(e); ServerListBox slb = (this.Parent as ServerGroupPanel)?.slb; if (slb != null) { slb.Visibility = Visibility.Collapsed; } UIElementCollection group = ((this.Parent as ServerGroupPanel)?.Parent as ServerGroupRootPanel)?.Children; if (group == null) { return; } int count = 0; for (int i = 0; i < group.Count; i++) { if ((group[i] as ServerGroupPanel).IsChecked == true) { count++; } } if (count < 1) { this.IsChecked = true; } }
public ServerGroupPanel() { this.Orientation = Orientation.Vertical; sgb = new ServerGroupButton(); this.Children.Add(sgb); slb = new ServerListBox(); this.Children.Add(slb); this.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; }
protected override void OnChecked(RoutedEventArgs e) { base.OnChecked(e); UIElementCollection group = ((this.Parent as ServerGroupPanel)?.Parent as ServerGroupRootPanel)?.Children; if (group == null) { return; } int idx = group.IndexOf(this.Parent as ServerGroupPanel); if (idx < 0) { return; } int i; for (i = 0; i < idx; i++) { if (group[i] as ServerGroupPanel != null) { (group[i] as ServerGroupPanel).VerticalAlignment = VerticalAlignment.Top; } (group[i] as ServerGroupPanel).IsChecked = false; } if (group[i] as ServerGroupPanel != null) { (group[i++] as ServerGroupPanel).VerticalAlignment = VerticalAlignment.Stretch; } for (; i < group.Count; i++) { if (group[i] as ServerGroupPanel != null) { (group[i] as ServerGroupPanel).VerticalAlignment = VerticalAlignment.Bottom; } (group[i] as ServerGroupPanel).IsChecked = false; } ServerListBox slb = (this.Parent as ServerGroupPanel)?.slb; if (slb != null) { slb.Visibility = Visibility.Visible; } }