I received feedback on this issue. As I understand, it has to do with making your app designer-aware by checking for DesignMode.
I solved this issue by executing the code that casts Window.Current.Content as a Frame only if DesignMode is not enabled.
The resulting code in GlobalNavPage_Loaded looks like this:
string currentFrameSourceName = "";
if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled || !Windows.ApplicationModel.DesignMode.DesignMode2Enabled)
{
currentFrameSourceName = ((Frame)Window.Current.Content).SourcePageType.ToString();
}
if (currentFrameSourceName == "WindowCurrentContentAsFrame.MainPage")
{
commandbar.SecondaryCommands.Add(HelpButton);
commandbar.SecondaryCommands.Add(AboutButton);
}
else
{
commandbar.SecondaryCommands.Add(AboutButton);
}
Now the XAML designer displays the XAML page correctly instead of throwing an InvalidCastException.