Holding an item steady against scrolling in scroll viewer in windows store app - layout

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>

Related

How to disable scrolling in coordinator layout based on screen size?

I am composing the screen with coordinarot layout and CollapsingToolbarLayout. I want it to scroll only when the container doesn't fill the view.
I want to use the scroll function only when the container doesn't fill the view. However, even when the container fills the view, it scrolls and there is a blank space at the bottom.
No matter how much I searched, I couldn't find a solution

How to animate resize/reposition of a Flutter Column when a child is added with a ScaleTransition

I'm implementing a login screen. It has a centred Column containing a TextField for entering an email address and a number of buttons for social sign-in. When a button is pressed, the Column is rebuilt with a CircularProgressIndicator (spinner) added at the bottom. I've wrapped the spinner in a custom widget that manages a ScaleTransition animation. That works OK, but the Column grows and shifts up to accommodate the final full size of the spinner immediately instead of moving smoothly with the animation.
I also wrapped the Column in an AnimatedSize widget using the same curve and duration as the ScaleTransition, but it hasn't helped. The root of the tree is a Consumer of the state that triggers the addition of the spinner so the animations should both be starting together. Maybe the the spinner needs to be permanent for this to work, but it doesn't seem desirable because its API doesn't provide a way to pause the animation. It would presumably constantly use some power to animate itself even when it isn't visible. I'm fussy about that sort of thing.
It looks like I might have to use an AnimatedList, but it doesn't seem semantically correct because the contents aren't really a list. So is there a more generic way to animate the size (and position) of parent widgets like Column and Center to track an animated size change of their children?

UI Virtualization of GridView and ListView in HubSection

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.

iOS view size and position hard-coded only?

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

ScrollView as subview does not respect frame boundaries

I have a UIScrollView (managed by a view controller) which I am using both full screen and as a subview. The full screen version works fine - the subview does not.
The subview is positioned so that it takes up about the bottom half of the screen, with a small - 20 pixels or so - margin at the bottom.
Initially it displays in the correct position but overwrites the bottom margin - even though the scrollview's frame is set to leave the margin.
When I scroll the view up by dragging it, the whole view moves upwards and obscures the top of the window. The frame stops moving when it hits the navigation bar at the top and starts scrolling like a normal scrollview. If I scroll it enough it eventually reveals the margin at the bottom of the screen.
I am at a loss to know what to do - I've tried every spring combination I can think of. I'm now looking at subview clipping.
Images below. The first shows the scrollview on initial page load, positioned correctly aside from lower margin overwrite. The scroll view has a white background.
The second image shows it scrolled up toward the top:
The third image shows it scrolled all the way up to the top - note that the lower margin has become visible.
I'm not 100% sure on this one, but worthy the shot: my guess is you're likely not setting the Bounds property correctly on your table.
To solve this issue, the easiest way would be to set myscrollview.clipsToBounds = true.
Something is definitely wrong here. I think what happens is that you are adding the same instance of scrollview as a subview on itself. So basically what you are left with, is one instance alone. Anything you add to the "subview", is basically added on the superview, since it is the same object.
For example, this is what I think you are doing in the view controller:
//...
private UIScrollView myScrollView;
public override void ViewDidLoad()
{
this.myScrollView = new UIScrollView();
this.View = this.myScrollView;
this.View.AddSubview(this.mySrcollView); // same instance
this.myScrollView.AddSubview(aUIButton); // "aUIButton" will be added in View also, since it is the same object
}
If this is the case, it is wrong. I suggest not changing the controller's view at all. If you want to have a controller that has a fullscreen UIScrollView, just create it and add it as a subview, making sure the AutoSizesSubviews property to true.
That's my understanding at least.

Resources