Lock Orientation for UWP Application

I recently needed to prevent screen rotation in a UWP application when running on a mobile device, but the application itself supports all orientations (Landscape, Portrait, LandscapeFlipped, PortraitFlipped). In order to achieve my desired result, I added a quick static method that I found here.

This goes in App.xaml.cs:

Now, in my MainPageViewModel.cs, my constructor looks like this:

This will force your application to stay in Portrait mode on a mobile device, regardless of the supported orientations in your Package.appxmanifest.