I just noticed that if I put a GridView or ListView in UWP app inside a HubSection, the UI Virtualization breaks. Is my understanding correct?
Thanks
Virtualization only happens for items outside the viewport. So it's important to place your GridView into a control that limits its size (e.g. Grid without auto-sized rows/columns) or set the size of the control. Wouldn't surprise me if your HubSection doesn't have a fixed size.
The concept of a viewport is critical to UI virtualization because the
framework must create the elements that are likely to be shown. In
general, the viewport of an ItemsControl is the extent of the logical
control. For example, the viewport of a ListView is the width and
height of the ListView element. Some panels allow child elements
unlimited space, examples being ScrollViewer and a Grid, with
auto-sized rows or columns. When a virtualized ItemsControl is placed
in a panel like that, it takes enough room to display all of its
items, which defeats virtualization. Restore virtualization by setting
a width and height on the ItemsControl.
Also custom templates often break virtualization:
If you provide a custom items panel template (see ItemsPanel) then
make sure you use a virtualizing panel such as ItemsWrapGrid or
ItemsStackPanel. If you use VariableSizedWrapGrid, WrapGrid, or
StackPanel, then you will not get virtualization.
More info on MSDN: UWP and Win8, which also has some good points that still count.
Related
I am working on windows 10 mobile app. If I design an UI for 5' device, it doesn't look good on 5.2' device. Also on emulators of different screen size show messed up UI. Is there any work around this? Or do I have to design it for every screen size?
Usually, please avoid to have fixed Width/Height for your controls. With a Grid layout, you can set columns/rows and place your controls inside each cells. This is a first level to adapt properly your interface. In addition, UWP provides AdaptiveTriggers if you want to adapt the layout based on the screen resolution (cf. https://channel9.msdn.com/Series/A-Developers-Guide-to-Windows-10/07) for additional information. Last but not least, please check Design&UI documention on https://developer.microsoft.com/en-us/windows/design.
The trick is with UWP that you can design for every screensize at once. It's just a responsive design you use (either HTML/CSS or XAML). But you have to use the right controls and settings.
Some guidance on how to design for various sizes can be found at the MSDN design page.
To create a dynamic layout with XAML, see this article. There are various panel-types you can use to do the layout (see this article). But if you really want to build a responsive UI (or change it dramatically in various sizes) RelativePanel is your friend.
I'm building my first Universal Windows Platform (UWP) App and am trying to implement the popular "Hamburger Menu" using the SplitView class.
Inspired by many samples, the items hosted on the SplitView pane are re-styled RadioButton controls, with a vertical highlight-rectangle, an icon and a text. The appearance is similar to that of the Groove app.
I'm now trying to implement navigation and selection using the keyboard, and this now bring a little focus-rect around the items in the SplitView pane. However, since the pane clips its contents when its DisplayMode is either CompactInline or CompactOverlay, the focus rectangle is also clipped, which is not the behavior a user would expect.
Please, can anyone advise on how to property display the focus rectangle in this situation ?
Just an idea, what if you set the width of all radio button's to be same as the CompactPaneLength property of SplitView. The default is 48 DIPs.
I want to hold a section label stable at the top of a ScrollViewer in a windows store app, while that section has not scrolled off. For example, the windows weather app does this with the section labels in the top left as you scroll to the right.
Currently the control I want to hold stable is nested inside a ScrollViewer control. I have an intermediate solution that holds it mostly steady by updating the control's render offset in response to the ViewChanged event. However, there's still some very obvious stuttering as I scroll. I've also considered "pretending" the control is in the scroll viewer, when it is actually outside of it, but this would break a lot of encapsulation.
How do I hold a section label perfectly still as the control it is logically inside of is scrolled over?
If you put the ScrollViewer and your Label into a Grid you can keep the label in the same position:
<Grid>
<Label/>
<ScrollViewer>...</ScrollViewer>
</Grid>
Basically, I have an usercontrol as main container, inside which I have a few groupboxes and buttons. But, my interface controls will not be resized and positioned properly as what I expect in design interface.
I've already tried to change the anchor and dock properties but none of them serve my purpose.
I searched online and found something called viewbox in WPF, I'm wondering if there is something like "viewbox" in visual studio 2010?
Please help!
Try using TableLayoutPanel container and put your controls in it. It is similar to the idea of table in HTML where it is divided to rows and columns each one of them can be set to either a set of pixels or a percentage. Usually if you want to use re-sizable form, usually you should have a control that will give you good results when stretching such as image, multiline textbox etc... In addition, put the dock property to fill to get the stretching you want.
I hope this info was useful for you.
I'm new to Macs and iOS, I got my app running on webOS, Android, and WPF/Windows. In all cases the size of, say, a 'widget' to display a bunch of text, can change depending on the dimension of the text to be displayed, as well as the position can be up against another widget. As the text size changes, the position will change so that all the widgets are crammed together nicely.
I've been searching for this capability in IOS4 in books and on-line, and it's starting to look like in iOS, you have to actually calculate the size of the text to be displayed in ViewText and then change the dimensions of ViewText, which of course then bumps other Views around to accommodate this size change. It sounds like a nightmare. Isn't there some other way to do this (like all the other GUIs can do) to size based on content, and to position relative to other Views like stacking them all together whatever size they are?
Same with ScrollView, it looks like the size of the window you actually see has to be manually specified as well, instead of, say, taking up the entire viewable window and then you can populate the ScrollView with a bunch of sub-views, some of which are below the initially viewable area? I tried this in Xcode4, but so far, haven't gotten it to work.
Similarly with creating an object with a NIB and instantiating that NIB onto an existing View, how does it determine where to position this NIB onto the existing screen?
Thanks!
Paul,
For the scrollview you need to set the bounds so it fills the screen or the area you wish it to occupy, it will then automatically generate scrollbars based on the layout within it. In the land of iOS you do have to do extensive layout work such as positioning and sizing your controls but you can also use the UIAutoResize (if I remember correctly) masks such as if they are anchored to a size, fill the area, etc. It's a little complicated to learn initially but you'll get the hang of it.
As for text you just need to use the right control, I believe what you want is a UITextView and set the options on it as needed.
When you view a XIB it's going to layout initially as you have it, again, you need to position your controls AND set their anchors (autoresize masks) so they adjust based on the screen size (phone vs. pad) and orientation: landscape vs. portrait.
HTH