public ConfigMenuPanel() { this.Orientation = Orientation.Vertical; button = new ConfigMenuButton(); this.Children.Add(button); detailView = new ConfigMenuTreeView(); this.Children.Add(detailView); AddConfigWorkGroupCommand = new RelayCommand(AddConfigWorkGroup); this.ContextMenu = new ContextMenu(); MenuItem item; item = new MenuItem(); item.Command = AddConfigWorkGroupCommand; item.Header = "Add Config Work Group"; item.Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.FolderPlus, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; this.ContextMenu.Items.Add(item); this.Background = Brushes.White; }
protected override void OnUnchecked(RoutedEventArgs e) { base.OnUnchecked(e); ConfigMenuTreeView detailView = (this.Parent as ConfigMenuPanel).DetailView; if (detailView != null) { detailView.Visibility = Visibility.Collapsed; } UIElementCollection group = ((this.Parent as ConfigMenuPanel)?.Parent as ConfigMenuRootPanel)?.Children; if (group == null) { return; } int count = 0; for (int i = 0; i < group.Count; i++) { if ((group[i] as ConfigMenuPanel).IsChecked == true) { count++; } } if (count < 1) { this.IsChecked = true; } }
protected override void OnChecked(RoutedEventArgs e) { base.OnChecked(e); ConfigMenuRootPanel root_pan = (this.Parent as ConfigMenuPanel)?.Parent as ConfigMenuRootPanel; if (root_pan == null) { return; } int idx = root_pan.Children.IndexOf(this.Parent as ConfigMenuPanel); int i; for (i = 0; i < idx; i++) { ConfigMenuPanel pan = root_pan.Children[i] as ConfigMenuPanel; if (pan != null) { pan.VerticalAlignment = VerticalAlignment.Top; } pan.IsChecked = false; } { ConfigMenuPanel pan = root_pan.Children[i++] as ConfigMenuPanel; if (pan != null) { pan.VerticalAlignment = VerticalAlignment.Stretch; } } for (; i < root_pan.Children.Count; i++) { ConfigMenuPanel pan = root_pan.Children[i] as ConfigMenuPanel; if (pan != null) { pan.VerticalAlignment = VerticalAlignment.Bottom; } pan.IsChecked = false; } ConfigMenuTreeView detailView = (this.Parent as ConfigMenuPanel)?.DetailView; if (detailView != null) { //if(root_pan != null) //{ // detailView.Margin = new Thickness(0, HEIGHT * (idx + 1), 0, HEIGHT * (root_pan.Children.Count - (idx + 1))); //} detailView.Visibility = Visibility.Visible; } }