NinjaBeetle
NinjaBeetle

Reputation: 85

WinJS window size

I'm building a small WinJS app just for Windows but can't seem to figure out how to set the size of the window at launch. There is obviously some preset size but I can't seem to resize it using CSS or trying to set the window's size directly.

How do you do it?

Upvotes: 2

Views: 1018

Answers (2)

NinjaBeetle
NinjaBeetle

Reputation: 85

It seems this is due to Microsoft wanting all apps in the Universal app eco-system to use responsive design. I was trying to set an initial screen/window size which doesn't really follow that pattern. If this had been for use on a phone or tablet that would make perfect sense, but the intended target was the desktop so I had hoped to circumvent that design.

I've decided the best course of action is to simply add a div with the correct dimensions and then resize the window (by hand/mouse) to fit around the area of the div since this is just for a personal use project.

Upvotes: 0

Mehdi Lahlou
Mehdi Lahlou

Reputation: 375

You can call this API:

var view = Windows.UI.ViewManagement.ApplicationView.getForCurrentView();
view.tryResizeView({ height: 500, width: 500 });
Windows.UI.ViewManagement.ApplicationView.preferredLaunchWindowingMode = Windows.UI.ViewManagement.ApplicationViewWindowingMode.preferredLaunchViewSize;
Windows.UI.ViewManagement.ApplicationView.preferredLaunchViewSize.height = 500;
Windows.UI.ViewManagement.ApplicationView.preferredLaunchViewSize.width = 500;

Upvotes: 3

Related Questions