Trying to implement full view in windows 10 mobile through code but it gives Unhandled exception while deploying on desktop view in windows 10

1

I'm trying to implement full view in Windows 10 mobile view through code. It's working fine in mobile, but when deploying the same code for desktop view I get the following error:

Unhandled exception at 0x00007FFCB9BFD1C4 (twinapi.appcore.dll) in L_c_uwp.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x000000C517DFECF0, 0x0000000000000001)

How to resolve this? Any suggestion would be appreciated.

XAML

<Grid>
    <MediaElement x:Name="myMediaElement"
        Source="/Video/splash_3.mp4" AutoPlay="True"
        CurrentStateChanged="MediaElement_CurrentStateChanged"/>
</Grid>

C# code

public MainPage()
{
    this.InitializeComponent();
    RemoveGap();
}

private void MediaElement_CurrentStateChanged(object sender, RoutedEventArgs e)
{
    if (myMediaElement.CurrentState == MediaElementState.Paused)
    {
        this.Frame.Navigate(typeof(Home));
    }
}

public async void RemoveGap()
{
    await StatusBar.GetForCurrentView().HideAsync();
}
c#
xaml
uwp
asked on Stack Overflow Dec 16, 2016 by anuj • edited Dec 16, 2016 by Decade Moon

1 Answer

2

Windows 10 Desktops does not have Status Bar so calling await StatusBar.GetForCurrentView().HideAsync(); causes error.

Instead, we need use the ApiInformation class to check for the presence of StatusBar as this class only exists in Mobile Device (See RequirementsDevice family).

if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
     await StatusBar.GetForCurrentView().HideAsync();

For more info, please see Dynamically detecting features with API contracts

answered on Stack Overflow Dec 16, 2016 by mister_giga • edited Dec 30, 2016 by Jay Zuo

User contributions licensed under CC BY-SA 3.0