I have been looking for a resizeable Universal Windows App (RT, UWP) control for handling different screen sizes and scalable controls. What I am looking for is something like a wrapgrid (What I am using below), except that it changes the column width to fill the space when it is resized, like what occurs with the Tubecast app for windows, when you resize the window the columns will expand, or when shrinking, merge once they hit a minimum value.
Currently I am using a wrapgrid control to fill the TV shows into the library, adding a new frame in code, navigating it to a new instance of the LibraryModel Page, passing a class via the onNavigatedTo() method. This XAML page has a min properties of 135x200, and a max properties of 270x400, using static item height and with of 270x400 and visual state groups to change to 125x200 when the width goes below 720px. I tried using a variablesizedwrapgrid, but it wasn't any more helpful.
Is there a control like this that exists for UWP apps? Or will it need to be created manually using C#, or added to the platform later? This control is likely essential for future Windows 10 App development. Example Screenshot
I figured out a way to make the controls scale to screen sizes, so that they will take up all available real estate, and works well on all devices.
Others shown at bottom of page..
This is the XAML structure required to scale the content. The
Viewbox
is wrapped into aGrid
, so that Vertical and Horizontal Alignment still works inside theScrollViewer
. The innerGrid
"Area" has its Height and Width bound to the baseGrid
'maingrid', so it maintains the aspect ratio of the page.The
Itemscontrol
is defined as aWrapGrid
, meaning that Item Width has to be defined, meaning this won't work variable sized controls inside (Although possible with some modification). TheItemTemplate
is then defined as well (Requiring the BaseGrid
'MainGrid' to be the same dimensions as the WrapGrid'sItemWidth
andItemHeight
).Events that are required are
SizeChanged
on the BaseGrid
andLoaded
on theItemsControl
.In order to scale the elements when the page is loaded, and scale them when the page is resized, the code looks like this:
The values of widths to change the number of rows will need to be manually tweaked in order to look better with different size objects, and when adding or removing from the
ItemSource
,Resize();
will have to be called to recalculate the dimensions of the elements, for it to look correct.You will, of course, need to replace
libraryitems
with you ownObservableCollection
, so that it can get the count of how many objects are in your list, or get the count from yourWrapGrid
's items count.