From f633bf440543181e5832331df954f3c662d176e7 Mon Sep 17 00:00:00 2001 From: Jaehyun Cho Date: Thu, 23 Feb 2023 17:01:30 +0900 Subject: [PATCH] [NUI] Fix Menu not to show Content if there is no menu item Menu.Content is a container of menu items. Previously, Menu.Content was displayed even if there is no menu item. Now, Menu.Content is displayed only if menu item exists. --- src/Tizen.NUI.Components/Controls/Menu.cs | 34 +++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/Tizen.NUI.Components/Controls/Menu.cs b/src/Tizen.NUI.Components/Controls/Menu.cs index bb16aca..4b129bd 100755 --- a/src/Tizen.NUI.Components/Controls/Menu.cs +++ b/src/Tizen.NUI.Components/Controls/Menu.cs @@ -165,13 +165,22 @@ namespace Tizen.NUI.Components set { + if (Content == null) + { + Content = CreateDefaultContent(); + if (styleApplied && (menuStyle != null)) + { + Content.ApplyStyle(menuStyle.Content); + } + } + if (menuItems != null) { foreach (var oldItem in menuItems) { - if (content.Children?.Contains(oldItem) == true) + if (Content.Children?.Contains(oldItem) == true) { - content.Remove(oldItem); + Content.Remove(oldItem); } } } @@ -180,12 +189,18 @@ namespace Tizen.NUI.Components if (menuItems == null) { + Content.SetVisible(false); return; } + if (Content.Visibility == false) + { + Content.SetVisible(true); + } + foreach (var item in menuItems) { - content.Add(item); + Content.Add(item); menuItemGroup.Add(item); } } @@ -482,12 +497,6 @@ namespace Tizen.NUI.Components // if Anchor has Layout, then Menu is displayed at an incorrect position. ExcludeLayouting = true; - Content = CreateDefaultContent(); - if (styleApplied && (menuStyle != null)) - { - Content.ApplyStyle(menuStyle.Content); - } - Scrim = CreateDefaultScrim(); menuItemGroup = new MenuItemGroup(); @@ -559,12 +568,7 @@ namespace Tizen.NUI.Components // If there is not enought space, then menu's size can be also resized. private void CalculateMenuPosition() { - if ((Anchor == null) || (Content == null)) - { - return; - } - - if (Items == null) + if (Anchor == null) { return; } -- 2.7.4