ScrollView Class
Used to navigate contents that are larger than the available size.
Example
This example demonstrates the use of ScrollView
by having it contain a Panel
that would normally be too big to be viewed.
<ScrollView>
<Panel Width="2000" Height="2000" />
</ScrollView>
You may also constrain the directions the ScrollView is allowed to scroll in using the AllowedScrollDirections
property.
<ScrollView AllowedScrollDirections="Horizontal">
<!-- Contents -->
</ScrollView>
By default, ScrollView tries to take up the same amount of space as its content in the scrollable directions. However, when placed in a Panel (or DockPanel, Grid, etc.), the size of the ScrollView itself will be limited to the size of its parent.
Note
StackPanel does not limit the size of its children, but rather lets them extend to whatever size they want to take up. This is a problem with ScrollView, since it inherits the size of its content by default. If we were to place a ScrollView inside a StackPanel, the size of the ScrollView would extend beyond the bounds of the screen. What we want instead is that only the ScrollView's content should extend to whatever size it needs, while the ScrollView itself is constrained to the bounds of its parent.
This means that a ScrollView inside a StackPanel probably won't behave as you expect it to. Alternatives include using a different type of Panel (e.g. a DockPanel) as the parent of the ScrollView or specifying its size explicitly.
The Alignment
of the child content influences the MinScroll
and MaxScroll
values as well as the starting ScrollPosition
.
For example a Bottom
aligned element will start with the bottom of the content visible (aligned to the bottom of the ScrollView
) and MinScroll
will be negative, as the overflow is to the top of the ScrollView
.
LayoutMode
By default a ScrollView
keeps a consistent ScrollPosition
when the layout changes. This may result in jumping when content is added/removed.
An alternate mode LayoutMode="PreserveVisual"
instead attempts to maintain visual consistency when its children or parent layout is changed. It assumes it's immediate content is a container and looks at that container's children. For example, a layout like this:
<ScrollView>
<StackPanel>
<Panel/>
<Panel/>
<StackPanel>
</ScrollView>
Visuals without LayoutRole=Standard
are not considered when retaining the visual consistency. The LayoutMode
property can be used to adjust this behavior.
Location
- Namespace
- Fuse.Controls
- Package
- Fuse.Controls.ScrollView 2.9.1
Interface of ScrollView
Inherited from ScrollViewBase
AllowedScrollDirections : ScrollDirections ux
GetVisualScrollPosition(Visual) : float2 uno
Obtain scroll position needed to scroll to the center of the Visual.
goto(absoluteX, absoluteY) js
Scroll to an absolute position (in points).
Goto(float2) uno
GotoRelative(float2) uno
Scrolls to a relative target position.
gotoRelative(relativeX, relativeY) js
Scroll to a relative position (range 0..1 over the full scrolling range).
KeepFocusInView : bool ux
By default a child with focus will be scrolled into view. Set KeepFocusInView
to false
to disable this behavior.
LayoutMode : ScrollViewLayoutMode ux
Specifies how ScrollPosition is modified when the control gets a new layout.
MaxOverflow : float2 uno
The extent of the maximum overflow (snapping) region. This is used only by gesture controls and will likely be deprecated as a public property.
MaxScroll : float2 uno
The maximum scroll position in points.
MinOverflow : float2 uno
The extent of the minimum overflow (snapping) region. This is used only by gesture controls and will likely be deprecated as a public property.
MinScroll : float2 uno
The minimum scroll position in points.
Motion : MotionConfig ux
The animation and scrolling behavior of a ScrollView
can be configured using ScrollViewMotion.
<ScrollView>
<ScrollViewMotion GotoEasing="Linear" GotoDuration="0.5"/>
<Panel>...content...</Panel>
</ScrollView>
RelativeScrollPosition : float2 ux
The relative position of the ScrollView
, from 0 at MinScroll
, to 1 at MaxScroll
.
ScrollPosition : float2 ux
ScrollPositionChanged : ScrollPositionChangedHandler (object, ScrollPositionChangedArgs) ux
Raised whenever the scroll position changes. This includes the aboslute position, the relative position and overflow/snapping position changes.
seekTo(absoluteX, absoluteY) js
Seek to an absolute position (in points). This bypasses the scrolling animation.
seekToRelative(relativeX, relativeY) js
Seek to a relative position (range 0..1 over the full scrolling range). This bypasses the scrolling animation.
SetScrollPosition(float2, IPropertyListener) uno
SnapMaxTransform : bool ux
If set to false
the contents will not visually scroll into the maximum snapping region (when the user scrolls beyond the bottom of the content). This region however still exists and can be used in ScrollingAnimation still.
SnapMinTransform : bool ux
If set to false
the contents will not visually scroll into the minimum snapping region (when the user scrolls beyond the top of the content). This region however still exists and can be used in ScrollingAnimation still.
UserScroll : bool ux
Enables/disables the ability for the user to scroll the control. When false
the user cannot interact with the control but it can still be scrolled programmatically.
Inherited from ContentControl
Content : Element ux
OnContentChanged uno
Inherited from Control
Appearance : object uno
Background : Brush ux
CreateNativeView : IView uno
DrawBackground(DrawContext, float) uno
DrawVisual(DrawContext) uno
GraphicsVisual : Visual uno
NativeView : IView uno
PushPropertiesToNativeView uno
Inherited from Element
ActualAnchor : float2 uno
ActualPosition : float2 uno
ActualSize : float2 uno
Alignment : Alignment ux
The Alignment of the Element
.
Anchor : Size2 ux
ArrangePaddingBox(LayoutParams) uno
Aspect : float ux
AspectConstraint : AspectConstraint ux
Determines how the aspect ratio is maintained in a situation when it violates the min or max sizing constraints.
BoxSizing : BoxSizingMode ux
The manner in which the size and position of the element is calculated.
CachingMode : CachingMode ux
CalcRenderBounds : VisualBounds uno
CalcRenderBoundsWithEffects : VisualBounds uno
CaptureRegion(DrawContext, Rect, float2) : framebuffer uno
ClipToBounds : bool ux
Clips the child elements to the bounds of this element visually.
DrawNonUnderlayChildren(DrawContext) uno
DrawUnderlayChildren(DrawContext) uno
DrawWithChildren(DrawContext) uno
ExplicitTransformOrigin : Size2 ux
FastTrackDrawWithOpacity(DrawContext) : bool uno
GetContentSize(LayoutParams) : float2 uno
GetVisibleViewportInvertPixelRect(DrawContext, VisualBounds) : Recti uno
Height : Size ux
HitTestLocalVisualBounds : VisualBounds uno
HitTestMode : HitTestMode ux
Specifies how hit tests should be performed on this element.
InvalidateRenderBoundsWithEffects uno
IsPointInside(float2) : bool uno
IsSelectionParentOf(Element) : bool uno
LimitHeight : Size ux
The height limit for an element using BoxSizing="Limit"
.
LimitWidth : Size ux
The width limit for an element using BoxSizing="Limit"
.
Margin : float4 ux
MaxHeight : Size ux
MaxWidth : Size ux
MinHeight : Size ux
MinWidth : Size ux
Offset : Size2 ux
OnDraw(DrawContext) uno
OnHitTestLocalVisual(HitTestContext) uno
Opacity : float ux
Padding : float4 ux
Placed : PlacedHandler (object, PlacedArgs) ux
Position : Size2 ux
RenderBoundsWithEffects : VisualBounds uno
RenderBoundsWithoutEffects : VisualBounds uno
SetExplicitTransformOrigin(Size2, IPropertyListener) uno
SetHitTestMode(HitTestMode, IPropertyListener) uno
SetOpacity(float, IPropertyListener) uno
SetVisibility(Visibility, IPropertyListener) uno
Size : Size2 ux
TransformOrigin : ITransformOrigin ux
TreeRenderer : ITreeRenderer uno
Visibility : Visibility ux
The Visibility of the Element
.
Width : Size ux
X : Size ux
Y : Size ux
Inherited from Visual
AbsoluteViewportOrigin : float2 uno
AbsoluteZoom : float uno
Add(Node) uno
AddDrawCost(double) uno
ArrangeMarginBox(float2, LayoutParams) : float2 uno
BeginInteraction(object, Action) uno
BeginRemoveChild(Node, Action<Node> (Node)) uno
Begins removing a given node, playing all RemovedAnimations before actual removal.
BeginRemoveVisual(Visual, Action<Node> (Node)) uno
Begins removing a given visual, playing all RemovedAnimations before actual removal.
BringIntoView uno
bringIntoView() js
Requests that this visual be brought into the visible are of the screen. Typically a containing
ScrollView
will scroll to ensure it is visible.
BringToFront(Visual) uno
Brings the given child to the front of the Z-order. In UX markup, use the BringToFront trigger action instead.
CancelInteractions(CancelInteractionsType) uno
ChildCount : int uno
The number of child nodes of this visual.
Children : IList of Node ux
The children of the visual. All nodes placed inside the visual in UX markup are assigned to this list. The order of Visuals this list determines the order of layout. The Z-order of the children is by default equal to this order, but can be manipulated separately using methods like BringToFront and SendToBack.
Draw(DrawContext) uno
DrawCost : double uno
EndInteraction(object) uno
FindTemplate(string) : Template uno
FindViewport : IViewport uno
FirstChild<T> : T uno
GetHitWindowPoint(float2) : Visual uno
GetMarginSize(LayoutParams) : float2 uno
GetTransformTo(Visual) : float4x4 uno
GetZOrderChild(int) : Visual uno
HasChildren : bool uno
HasPendingRemove : bool uno
HasVisualChildren : bool uno
Whether this visual has any visual child nodes.
HitTest(HitTestContext) uno
HitTestBounds : VisualBounds uno
HitTestChildrenBounds : VisualBounds uno
HitTestLocalBounds : VisualBounds uno
IfSnap(float2) : float2 uno
IfSnapDown(float2) : float2 uno
IfSnapUp(float2) : float2 uno
Insert(int, Node) uno
InsertAfter(Node, Node) uno
InvalidateHitTestBounds uno
InvalidateLayout(InvalidateLayoutReason) uno
InvalidateLocalTransform uno
InvalidateRenderBounds uno
InvalidateVisual uno
Indicates the visual for this node has changed. This allows the root-level node to know that it must draw, and any caching that it must invalidate the cache for this node.
InvalidateVisualComposition uno
Indicates the composition of the visual has changed, but that the visual drawing itself is still valid (for example a position change).
IsContextEnabled : bool uno
Whether this node is in an enabled context.
The context is disabled if one of the ancestor nodes have IsEnabled set to false
.
IsEnabled : bool ux
IsInteracting : bool uno
IsLocalVisible : bool uno
Returns whether this visual is visible without concern for whether an ancestor visual is hidden or collapsed.
IsMarginBoxDependent(Visual) : LayoutDependent uno
IsVisible : bool uno
Returns whether this visual is currently visible. Will return false if any of the ancestor visuals are hidden or collapsed. This property can not be used to check whether a visual is hidden because it is occluded by another visual, or is outside the view but otherwise visible.
LastChild<T> : T uno
Layer : Layer ux
The layer this visual belongs to in the Parent container.
LayoutRole : LayoutRole ux
Describes how this visual participates in layout.
LocalBounds : Box uno
LocalRenderBounds : VisualBounds uno
LocalToParent(float2) : float2 uno
Converts a coordinate from the local space into the parent space.
LocalTransform : float4x4 uno
LocalTransformInternal : FastMatrix uno
LocalTransformInverse : float4x4 uno
OnArrangeMarginBox(float2, LayoutParams) : float2 uno
OnBeginRemoveVisual(PendingRemoveVisual) uno
OnChildAdded(Node) uno
OnChildMoved(Node) uno
OnChildRemoved(Node) uno
OnHitTest(HitTestContext) uno
OnInvalidateLayout uno
OnInvalidateRenderBounds : bool uno
OnInvalidateVisual uno
OnInvalidateVisualComposition uno
OnIsContextEnabledChanged uno
OnIsSelectedChanged(bool) uno
OnIsVisibleChanged uno
OnLocalVisibleChanged uno
onParameterChanged(callback) js
OnPropertyChanged(PropertyObject, Selector) uno
OnRootedPreChildren uno
OnZOrderInvalidated uno
Parameter : string ux
PerformLayout uno
PerformLayout(float2) uno
PrependImplicitTransform(FastMatrix) uno
PrependInverseTransformOrigin(FastMatrix) uno
PrependTransformOrigin(FastMatrix) uno
Remove(Node) : bool uno
RemoveAllChildren<T> uno
RemoveDrawCost(double) uno
Resources : IList of Resource ux
The list of resources defined at this node.
SendToBack(Visual) uno
Sends the given child to the back of the Z-order. In UX markup, use the SendToBack trigger action instead.
SetResource(string, object) uno
Snap(float2) : float2 uno
SnapDown(float2) : float2 uno
SnapToPixels : bool ux
Whether to snap the result of layout of this visual to physical device pixels.
SnapUp(float2) : float2 uno
Templates : IList of Template ux
TryParentToLocal(float2, float2) : bool uno
Converts a coordinate from the parent space into the local space.
ValidFrameCount : int uno
ViewHandle : ViewHandle uno
Viewport : IViewport uno
VisualChildCount : int uno
The number of child visuals of this visual.
VisualContext : VisualContext uno
WindowToLocal(float2) : float2 uno
WorldPosition : float3 uno
WorldTransform : float4x4 uno
WorldTransformInverse : float4x4 uno
ZOffset : float ux
Inherited from Node
Add(Binding) uno
Bindings : IList of Binding ux
The list of bindings belonging to this node.
ContextParent : Node uno
The context parent is the semantic parent of this node. It is where non-UI structure should be resolved, like looking for the DataContext, a Navigation, or other semantic item.
FindByType<T> : T uno
FindNodeByName(Selector, Predicate<Node> (Node)) : Node uno
Finds the first node with a given name that satisfies the given acceptor. The serach algorithm works as follows: Nodes in the subtree are matched first, then it matches the nodes in the subtrees ofthe ancestor nodes by turn all the way to the root. If no matching node is found, the function returns null.
GetNearestAncestorOfType<T> : T uno
Insert(int, Binding) uno
IsRootingCompleted : bool uno
Whether rooting for this node is completed. Returns false if unrooting has started.
IsRootingStarted : bool uno
Whether rooting of this node has started. Note that even if this property returns true, rooting may not yet be completed for the node. See also IsRootingCompleted.
Name : Selector ux
Run-time name of the node. This property is automatically set using the ux:Name attribute.
NextSibling<T> : T uno
Returns the next sibling node of the given type.
OnDataChanged(string, object) uno
OnRooted uno
If you override OnRooted
you must call base.OnRooted()
first in your derived class. No other processing should happen first, otherwise you might end up in an undefined state.
OnUnrooted uno
Parent : Visual uno
The parent Visual of this node. Will return null if the node is not rooted.
PreviousSibling<T> : T uno
Returns the next sibling node of the given type.
Properties : Properties uno
A linked list holding data for extrinsic properties.
Remove(Binding) : bool uno
SoftDispose uno
SourceFileName : string ux
hide
SourceLineNumber : int ux
hide
SubtreeToString : string uno
SubtreeToString(StringBuilder, int) uno
TryGetResource(string, Predicate<object> (object), object) : bool uno
VisitSubtree(Action<Node> (Node)) uno
Inherited from PropertyObject
AddPropertyListener(IPropertyListener) uno
OnPropertyChanged(Selector, IPropertyListener) uno
OnPropertyChanged(Selector) uno
RemovePropertyListener(IPropertyListener) uno
Inherited from object
Equals(object) : bool uno
GetHashCode : int uno
GetType : Type uno
ToString : string uno
Attached UX Attributes
ColorScheme (attached by Resources) : ColorScheme ux
Dock (attached by DockPanel) : Dock ux
Specifies how an element is docked while inside a DockPanel
Items (attached by Each) : object ux
MatchKey (attached by Each) : string ux
Shorthand for setting the MatchKey
property on the implicit Each
created when using the Items
attached property.
Edge (attached by EdgeNavigation) : NavigationEdge ux
LayoutMaster (attached by LayoutControl) : Element ux
Delegate (attached by Focus) : Visual ux
Gained (attached by AttachedFocusMembers) : FocusGainedHandler (object, FocusGainedArgs) ux
Called when a Visual receives input focus.
IsFocusable (attached by Focus) : bool ux
Lost (attached by AttachedFocusMembers) : FocusLostHandler (object, FocusLostArgs) ux
Called when a Visual loses input focus.
Clicked (attached by Clicked) : ClickedHandler (object, ClickedArgs) ux
Tapped (attached by Tapped) : TappedHandler (object, TappedArgs) ux
Column (attached by Grid) : int ux
The index of the column the element occupies while in a Grid. If not set, the grid will place the element in a cell according to its position in the child list.
ColumnSpan (attached by Grid) : int ux
The number of columns this element occupies in a Grid. Defaults to 1.
Row (attached by Grid) : int ux
The index of the row the element occupies while in a Grid. If not set, the grid will place the element in a cell according to its position in the child list.
RowSpan (attached by Grid) : int ux
The number of rows this element occupies in a Grid. Defaults to 1.
Model (attached by ModelJavaScript) : string ux
KeyPressed (attached by AttachedKeyboardMembers) : KeyPressedHandler (object, KeyPressedArgs) ux
Called when a Visual receives a key press event while having input focus. On mobile devices, keyboard input only applies to physical buttons (such as BackButton), not soft keyboards.
KeyReleased (attached by AttachedKeyboardMembers) : KeyReleasedHandler (object, KeyReleasedArgs) ux
Called when a Visual receives a key release event while having input focus. On mobile devices, keyboard input only applies to physical buttons (such as BackButton), not soft keyboards.
FillPadding (attached by Layout) : bool ux
LayoutMasterMode (attached by LayoutMasterAttr) : LayoutMasterMode ux
Determines how the layout of the master element is used to control the size of this one.
ModelArgs (attached by ModelJavaScript) : IExpression ux
ModelNameTable (attached by ModelJavaScript) : NameTable ux
Activated (attached by Activated) : PulseHandler (object, EventArgs) ux
Adds a handler for when the page is Activated
Deactivated (attached by Deactivated) : PulseHandler (object, EventArgs) ux
Adds a handler for when the page is Deactivated
Navigation (attached by Navigation) : IBaseNavigation ux
Page (attached by NavigationPageProperty) : Visual ux
Transition (attached by NavigationControl) : NavigationControlTransition ux
Remove (attached by Navigator) : RemoveType ux
Reuse (attached by Navigator) : ReuseType ux
SwipeBack (attached by Navigator) : NavigatorSwipeDirection ux
Friction (attached by BodyAttr) : float ux
IsPhysicsWorld (attached by World) : bool ux
Entered (attached by AttachedPointerMembers) : PointerEnteredHandler (object, PointerEnteredArgs) ux
Called when a pointer enters a visual.
Left (attached by AttachedPointerMembers) : PointerLeftHandler (object, PointerLeftArgs) ux
Called when a pointer leaves a visual.
Moved (attached by AttachedPointerMembers) : PointerMovedHandler (object, PointerMovedArgs) ux
Called when a pointer is moved on a visual.
Pressed (attached by AttachedPointerMembers) : PointerPressedHandler (object, PointerPressedArgs) ux
Called when a pointer is pressed on the visual.
Released (attached by AttachedPointerMembers) : PointerReleasedHandler (object, PointerReleasedArgs) ux
Called when a pointer is released on a visual.
WheelMoved (attached by AttachedPointerMembers) : PointerWheelMovedHandler (object, PointerWheelMovedArgs) ux
Called when a pointer wheel is moved on a visual.
GlobalKey (attached by Resource) : string ux
Implemented Interfaces
IScrollViewHost uno
IShow uno
IHide uno
ICollapse uno
IActualPlacement uno
IResize uno
IList<Node> uno
IPropertyListener uno
ITemplateSource uno
IEnumerable<Visual> uno
ICollection<Node> uno
IEnumerable<Node> uno
IList<Binding> uno
IScriptObject uno
Interface for objects that can have a script engine representation
IProperties uno
ISourceLocation uno
hide