C
C#2w ago
pwl

wierd menuitem issue: whole menu closes once deeper than 2 menuitems

I'm trying to make a drop-down menu that goes deeper than 2 items, the problem being that the whole menu closes once i try to go further than two menuitems (counting in the initial parent one), the whole thing looks something like this [Initial parent menuitem] -test1 -test2 --- whole menu closes once i try to expand this one -test3 this is what the xaml for the menu looks like, the seperator being so it can be opened and the submenuopened code runs;
<ui:MenuItem x:Name="StartMenuTab" SubmenuOpened="ListStartMenuItems" Header="Start Folder Apps" Icon="{ui:SymbolIcon AppsList20}">
<Separator/>
</ui:MenuItem>
<ui:MenuItem x:Name="StartMenuTab" SubmenuOpened="ListStartMenuItems" Header="Start Folder Apps" Icon="{ui:SymbolIcon AppsList20}">
<Separator/>
</ui:MenuItem>
and this is the ListStartMenuItems method;
private void ListStartMenuItems(object sender, RoutedEventArgs e)
{
StartMenuTab.Items.Clear();

string[] placeholderDirs = { "test","test","test","test" };
foreach (var subdir in placeholderDirs)
{
var subFolderMenuItem = new MenuItem
{
Header = subdir,
Icon = new SymbolIcon(SymbolRegular.Folder24),
};

var placeholder = new MenuItem
{
Header = "Placeholder",
};
subFolderMenuItem.Items.Add(placeholder);

StartMenuTab.Items.Add(subFolderMenuItem);
}
}
private void ListStartMenuItems(object sender, RoutedEventArgs e)
{
StartMenuTab.Items.Clear();

string[] placeholderDirs = { "test","test","test","test" };
foreach (var subdir in placeholderDirs)
{
var subFolderMenuItem = new MenuItem
{
Header = subdir,
Icon = new SymbolIcon(SymbolRegular.Folder24),
};

var placeholder = new MenuItem
{
Header = "Placeholder",
};
subFolderMenuItem.Items.Add(placeholder);

StartMenuTab.Items.Add(subFolderMenuItem);
}
}
worth to mention that i'm using WPFUI by Lepco; https://wpfui.lepo.co/documentation/ i found this but i'm not sure what to make of it https://wpfui.lepo.co/api/Wpf.Ui.Controls.MenuItem.html
wpfui.lepo.co
wpfui.lepo.co
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?