UWP portrait mode for kiosk desktop app?

Viewed 860

Evaluating UWP for a Windows desktop app which must run in portrait mode for kiosk hardware. This seem to be a problem for UWP as desktop apps apparently assume landscape... any workarounds or is this just the wrong technology?

Is it possible to extend the list of target devices available in the design view?

2 Answers

I see a lot of sub sections to your question, do let me know if I've missed out something. Below are the sections:

Getting a forced portrait mode in designer:

So in-case you have a desirable screen height and width what you can do are:

  1. Select the device from the designer's device list that matches the pixel ratio and scale. (ignore the height and width).
  2. Now that you have a rough estimate of your designer, now you need to set it to your required size. To do so, in your <Page> tag of the xaml add the below declarations along with the namespace declarations.

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="500"
d:DesignWidth="300"

The above code would set your designer to the size you want and the scale and aspect ratio is set from the device that you had picked. And you can design for the size your hardware as you know the size of the deployed machine won't change.

Making the app run in Forced Portrait mode:

Well the UWP apps are meant to be adaptive which is kinda the best part about them, make once and deploy to a wide variety of your machines.

That being said, refer to this section only if you have a case scenario where in your app can be deployed to a landscape mode hardware and you want your app to still be in portrait mode. If so, then there are two ways you can go about it.

  1. Use MaxHeight and MaxWidth of your root grid or any parent (except for page) to set it to what you want so that even if the app is running fullscreen, your content will be aligned vertically center and won't go more than what you've set and the remaining window would be filled with the background that you've set.
  2. You can also set the app size while starting and then listen to the size changed event of your app, so that each time the size is changed and it falls off from the portrait mode, your set it back to portrait mode.

I am writing up a quick demo app for your better understanding. I'll add the link in a while.


Personally I think, a UWP app is best suited for your use case, as you have no idea what would be size of your deployment screen and you can actually leverage the adaptive layout of UWP, to ship your app to different vendors

You can configure in which mode should your application run by setting in the Package.appxmanifest file's Application tab

enter image description here

Related