/// <summary> /// Initializes the menu components. /// </summary> public void LateInitialize() { // adding the head of the menu to the list of menus AllMenuTitles.Add(Items[0].Header); foreach (var t in Items) { Game.Components.Add(t); // Add the child component to the game with the modified parameters. if (t.Items.Count > 0) { AllSubMenuTitles.Add(t.Header); if (!OpenSubMenuDictionary.ContainsKey(t.Header)) { OpenSubMenuDictionary.Add(t.Header, false); } } } Items[0].Width += (int)Items[0].Padding.Left + (int)Items[0].Padding.Right; Items[0].Height += (int)Items[0].Padding.Top + (int)Items[0].Padding.Bottom; Items[0].Margin = new Thickness(Margin.Left, Margin.Top, Margin.Right, Margin.Bottom); CalculateGreatestWidth(); SetWidthAndHeight(); IsEnabled = true; _lateInitialize = true; }
/// <summary> /// Loads the children once the grid has been set up. /// </summary> private void LateInitialize() { _lateInitialize = true; if (Items.Count > 0) { foreach (var t in Items) { Game.Components.Add(t); } // space for the arrow to draw. Width += 20; // Add the header to the list of submenus so that its parent // menus will not close. AllSubMenuTitles.Add(Header); if (!OpenSubMenuDictionary.ContainsKey(Header)) { OpenSubMenuDictionary.Add(Header, false); } CalculateGreatestWidth(); SetWidthAndHeight(); foreach (var t in Items) { t.Visible = Visibility.Hidden; t.HorizontalAlignment = HorizontalAlignment; t.VerticalAlignment = VerticalAlignment; } } }