ScrollViewer Class
Namespace: Stride.UI.ControlsAssembly: Stride.UI.dll
Represents a scroll viewer. A scroll viewer element has an infinite virtual size defined by its ScrollingMode. The user can move in that virtual size by touching and panning on the screen.
[DataContract("ScrollViewer")]
[DataContractMetadataType(typeof(ScrollViewer.ScrollViewerMetadata))]
public class ScrollViewer : ContentControl, IUIElementUpdate, IUIElementChildren, IIdentifiable
Name | Description | |
---|---|---|
Constructors | ||
ScrollViewer() | ||
Fields | ||
CurrentScrollingSpeed | The current speed of the scrolling in virtual pixels. |
|
ScrollOffsets | The current offsets (in virtual pixels) generated by the scrolling on the Content element. |
|
Properties | ||
Content | ||
ContentAsAnchorInfo | The current content casted as IScrollAnchorInfo |
|
ContentAsScrollInfo | The current content casted as IScrollInfo. |
|
Deceleration | The automatic deceleration of the scroll after the user remove its finger from the screen. The unit is in virtual pixels. |
|
IsEnabled | ||
IsTouchedDown | Gets a value that indicates whether the is currently touched down. |
|
IsUserScrollingViewer | Indicate if the user is currently touching the scroll viewer and performing a scroll gesture with its finger. |
|
LastFrameTranslation | Gets the scrolling translation that occurred during the last frame |
|
ScrollBarColor | Gets or sets the color of the scrolling bar. |
|
ScrollBarThickness | Gets or sets the scrolling bar thickness in virtual pixels. |
|
ScrollMode | The viewer allowed scrolling mode. |
|
ScrollPosition | The current scroll position (in virtual pixels) of the ScrollViewer. That is, the position of the left-top-front corner of the ScrollViewer in its Content. |
|
ScrollStartThreshold | Gets or sets the threshold distance over which a touch move starts scrolling. |
|
SnapToAnchors | Gets or sets the value indicating if the element should snap its scrolling to anchors. |
|
TouchScrollingEnabled | Gets or sets the scrolling behavior on touches. True to allow the user to scroll by touching, false to forbid it. |
|
ViewPort | The viewport of the ScrollViewer in virtual pixels. |
|
Methods | ||
ArrangeOverride(Vector3) | ||
CanScroll(Orientation) | Indicate if the scroll viewer can scroll in the given direction. |
|
HideScrollBars() | ||
InvalidateAnchorInfo() | Called by an IScrollAnchorInfo interface that attached to a ScrollViewer when the value of any anchor changed. |
|
InvalidateScrollInfo() | Called by an IScrollInfo interface that is attached to a ScrollViewer when the value of any scrolling property size changes. Scrolling properties include offset, extent, or viewport. |
|
MeasureOverride(Vector3) | ||
OnPreviewTouchDown(TouchEventArgs) | ||
OnPreviewTouchMove(TouchEventArgs) | ||
OnPreviewTouchUp(TouchEventArgs) | ||
OnScrollModeChanged() | Method triggered when ScrollMode changed. Can be overridden in inherited class to change the default behavior. |
|
OnTouchEnter(TouchEventArgs) | ||
OnTouchLeave(TouchEventArgs) | ||
OnTouchScrollingEnabledChanged() | Method triggered when TouchScrollingEnabled changed. Can be overridden in inherited class to change the default behavior. |
|
ScrollOf(Vector3, Boolean) | Try to scroll of the provided scrolling translation value from the current position. If the provided translation is too important, it is clamped. |
|
ScrollOfInternal(ref Vector3, Boolean) | ||
ScrollTo(Vector3, Boolean) | Try to scroll to the provided position (in virtual pixels). If the provided translation is too important, it is clamped. |
|
ScrollToBeginning(Orientation, Boolean) | Go to the beginning of the scroll viewer's content in the provided direction. |
|
ScrollToEnd(Orientation, Boolean) | Go to the end of the scroll viewer's content in the provided direction. |
|
StopCurrentScrolling() | Stops the scrolling at the current position. |
|
Update(GameTime) | ||
UpdateWorldMatrix(ref Matrix, Boolean) |
Constructors
ScrollViewer()
public ScrollViewer()
Fields
CurrentScrollingSpeed
The current speed of the scrolling in virtual pixels.
protected Vector3 CurrentScrollingSpeed
Field Value
Type | Description |
---|---|
Vector3 |
ScrollOffsets
The current offsets (in virtual pixels) generated by the scrolling on the Content element.
protected Vector3 ScrollOffsets
Field Value
Type | Description |
---|---|
Vector3 |
Properties
Content
public override UIElement Content { get; set; }
Property Value
Type | Description |
---|---|
UIElement |
Overrides
ContentAsAnchorInfo
The current content casted as IScrollAnchorInfo
protected IScrollAnchorInfo ContentAsAnchorInfo { get; }
Property Value
Type | Description |
---|---|
IScrollAnchorInfo |
Remarks
ContentAsScrollInfo
The current content casted as IScrollInfo.
protected IScrollInfo ContentAsScrollInfo { get; }
Property Value
Type | Description |
---|---|
IScrollInfo |
Remarks
Deceleration
The automatic deceleration of the scroll after the user remove its finger from the screen. The unit is in virtual pixels.
[DataMember]
[Display(null, "Behavior")]
public float Deceleration { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
IsEnabled
public override bool IsEnabled { set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
IsTouchedDown
Gets a value that indicates whether the is currently touched down.
protected virtual bool IsTouchedDown { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsUserScrollingViewer
Indicate if the user is currently touching the scroll viewer and performing a scroll gesture with its finger.
protected bool IsUserScrollingViewer { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
LastFrameTranslation
Gets the scrolling translation that occurred during the last frame
protected Vector3 LastFrameTranslation { get; }
Property Value
Type | Description |
---|---|
Vector3 |
ScrollBarColor
Gets or sets the color of the scrolling bar.
[DataMember]
[Display(null, "Appearance")]
public Color ScrollBarColor { get; set; }
Property Value
Type | Description |
---|---|
Color |
ScrollBarThickness
Gets or sets the scrolling bar thickness in virtual pixels.
[DataMember]
[Display(null, "Appearance")]
public float ScrollBarThickness { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
ScrollMode
The viewer allowed scrolling mode.
[DataMember]
[Display(null, "Behavior")]
public ScrollingMode ScrollMode { get; set; }
Property Value
Type | Description |
---|---|
ScrollingMode |
ScrollPosition
The current scroll position (in virtual pixels) of the ScrollViewer. That is, the position of the left-top-front corner of the ScrollViewer in its Content.
public Vector3 ScrollPosition { get; }
Property Value
Type | Description |
---|---|
Vector3 |
Remarks
If the Content of the scroll viewer implements the IScrollInfo interface,
the ScrollPosition will be
Note that ScrollPosition is valid only when IsArrangeValid is
ScrollStartThreshold
Gets or sets the threshold distance over which a touch move starts scrolling.
[DataMember]
[Display(null, "Behavior")]
public float ScrollStartThreshold { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
SnapToAnchors
Gets or sets the value indicating if the element should snap its scrolling to anchors.
[DataMember]
[Display(null, "Behavior")]
public bool SnapToAnchors { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
Snapping will work only if Content implements interface IScrollAnchorInfo
TouchScrollingEnabled
Gets or sets the scrolling behavior on touches. True to allow the user to scroll by touching, false to forbid it.
[DataMember]
[Display(null, "Behavior")]
public bool TouchScrollingEnabled { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
ViewPort
The viewport of the ScrollViewer in virtual pixels.
public Vector3 ViewPort { get; }
Property Value
Type | Description |
---|---|
Vector3 |
Methods
ArrangeOverride(Vector3)
protected override Vector3 ArrangeOverride(Vector3 finalSizeWithoutMargins)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | finalSizeWithoutMargins |
Returns
Type | Description |
---|---|
Vector3 |
Overrides
CanScroll(Orientation)
Indicate if the scroll viewer can scroll in the given direction.
public bool CanScroll(Orientation direction)
Parameters
Type | Name | Description |
---|---|---|
Orientation | direction | The direction to use for the test |
Returns
Type | Description |
---|---|
System.Boolean |
HideScrollBars()
protected void HideScrollBars()
InvalidateAnchorInfo()
Called by an IScrollAnchorInfo interface that attached to a ScrollViewer when the value of any anchor changed.
public void InvalidateAnchorInfo()
InvalidateScrollInfo()
Called by an IScrollInfo interface that is attached to a ScrollViewer when the value of any scrolling property size changes. Scrolling properties include offset, extent, or viewport.
public void InvalidateScrollInfo()
MeasureOverride(Vector3)
protected override Vector3 MeasureOverride(Vector3 availableSizeWithoutMargins)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | availableSizeWithoutMargins |
Returns
Type | Description |
---|---|
Vector3 |
Overrides
OnPreviewTouchDown(TouchEventArgs)
protected override void OnPreviewTouchDown(TouchEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
TouchEventArgs | args |
Overrides
OnPreviewTouchMove(TouchEventArgs)
protected override void OnPreviewTouchMove(TouchEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
TouchEventArgs | args |
Overrides
OnPreviewTouchUp(TouchEventArgs)
protected override void OnPreviewTouchUp(TouchEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
TouchEventArgs | args |
Overrides
OnScrollModeChanged()
Method triggered when ScrollMode changed. Can be overridden in inherited class to change the default behavior.
protected virtual void OnScrollModeChanged()
OnTouchEnter(TouchEventArgs)
protected override void OnTouchEnter(TouchEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
TouchEventArgs | args |
Overrides
OnTouchLeave(TouchEventArgs)
protected override void OnTouchLeave(TouchEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
TouchEventArgs | args |
Overrides
OnTouchScrollingEnabledChanged()
Method triggered when TouchScrollingEnabled changed. Can be overridden in inherited class to change the default behavior.
protected virtual void OnTouchScrollingEnabledChanged()
ScrollOf(Vector3, Boolean)
Try to scroll of the provided scrolling translation value from the current position. If the provided translation is too important, it is clamped.
public void ScrollOf(Vector3 scrollTranslation, bool stopScrolling = true)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | scrollTranslation | The scroll translation to perform (in virtual pixels) |
System.Boolean | stopScrolling | Indicate if the scrolling should be stopped after the scroll action. |
ScrollOfInternal(ref Vector3, Boolean)
public void ScrollOfInternal(ref Vector3 scrollTranslation, bool stopScrolling)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | scrollTranslation | |
System.Boolean | stopScrolling |
ScrollTo(Vector3, Boolean)
Try to scroll to the provided position (in virtual pixels). If the provided translation is too important, it is clamped.
public void ScrollTo(Vector3 scrollAbsolutePosition, bool stopScrolling = true)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | scrollAbsolutePosition | The scroll offsets to apply |
System.Boolean | stopScrolling | Indicate if the scrolling should be stopped after the scroll action. |
Remarks
Note that the computational cost of ScrollTo(Vector3, Boolean) can be greatly higher than ScrollOf(Vector3, Boolean) when scrolling is delegated to a Content virtualizing its items. When possible, prefer call to ScrollOf(Vector3, Boolean)
ScrollToBeginning(Orientation, Boolean)
Go to the beginning of the scroll viewer's content in the provided direction.
public void ScrollToBeginning(Orientation direction, bool stopScrolling = true)
Parameters
Type | Name | Description |
---|---|---|
Orientation | direction | The direction in which to scroll |
System.Boolean | stopScrolling | Indicate if the scrolling should be stopped after the scroll action. |
ScrollToEnd(Orientation, Boolean)
Go to the end of the scroll viewer's content in the provided direction.
public void ScrollToEnd(Orientation direction, bool stopScrolling = true)
Parameters
Type | Name | Description |
---|---|---|
Orientation | direction | The direction in which to scroll |
System.Boolean | stopScrolling | Indicate if the scrolling should be stopped after the scroll action. |
StopCurrentScrolling()
Stops the scrolling at the current position.
public void StopCurrentScrolling()
Update(GameTime)
protected override void Update(GameTime time)
Parameters
Type | Name | Description |
---|---|---|
GameTime | time |
Overrides
UpdateWorldMatrix(ref Matrix, Boolean)
protected override void UpdateWorldMatrix(ref Matrix parentWorldMatrix, bool parentWorldChanged)
Parameters
Type | Name | Description |
---|---|---|
Matrix | parentWorldMatrix | |
System.Boolean | parentWorldChanged |