Skip to content

Commit

Permalink
Safeguard TopMenuBar iterating
Browse files Browse the repository at this point in the history
  • Loading branch information
LaughingLeader committed Jul 23, 2021
1 parent 8d7e3dc commit 426cb94
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions GUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,19 @@ private void RegisterBindings()
this.InputBindings.Add(keyBinding);
}

foreach (var entry in TopMenuBar.Items.Cast<MenuItem>())
foreach (var item in TopMenuBar.Items)
{
menuItems.Add((string)entry.Header, entry);
if(item is MenuItem entry)
{
if (entry.Header is string label)
{
menuItems.Add(label, entry);
}
else if (!String.IsNullOrWhiteSpace(entry.Name))
{
menuItems.Add(entry.Name, entry);
}
}
}

//Generating menu items
Expand Down

0 comments on commit 426cb94

Please sign in to comment.