Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    ScrollViewer Class

    Namespace: Stride.UI.Controls
    Assembly: 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.

    System.Object → UIElement → Control → ContentControl → ScrollViewer
    Derived from ScrollViewer:

    [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)
    | Improve this Doc View Source

    Constructors


    ScrollViewer()

    public ScrollViewer()
    | Improve this Doc View Source

    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
    | Improve this Doc View Source

    Properties


    Content

    public override UIElement Content { get; set; }
    Property Value
    Type Description
    UIElement
    Overrides
    ContentControl.Content

    ContentAsAnchorInfo

    The current content casted as IScrollAnchorInfo

    protected IScrollAnchorInfo ContentAsAnchorInfo { get; }
    Property Value
    Type Description
    IScrollAnchorInfo
    Remarks

    Null if the Content does not implement the interface


    ContentAsScrollInfo

    The current content casted as IScrollInfo.

    protected IScrollInfo ContentAsScrollInfo { get; }
    Property Value
    Type Description
    IScrollInfo
    Remarks

    Null if the Content does not implement the interface


    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
    UIElement.IsEnabled

    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 0 in all directions where CanScroll(Orientation) is true.

    Note that ScrollPosition is valid only when IsArrangeValid is true. If IsArrangeValid is false, ScrollPosition contains the position of the scrolling before the action that actually invalidated the layout.


    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
    | Improve this Doc View Source

    Methods


    ArrangeOverride(Vector3)

    protected override Vector3 ArrangeOverride(Vector3 finalSizeWithoutMargins)
    Parameters
    Type Name Description
    Vector3 finalSizeWithoutMargins
    Returns
    Type Description
    Vector3
    Overrides
    ContentControl.ArrangeOverride(Vector3)

    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 true if the scroll viewer can scroll in the provided direction, or else false

    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
    ContentControl.MeasureOverride(Vector3)

    OnPreviewTouchDown(TouchEventArgs)

    protected override void OnPreviewTouchDown(TouchEventArgs args)
    Parameters
    Type Name Description
    TouchEventArgs args
    Overrides
    UIElement.OnPreviewTouchDown(TouchEventArgs)

    OnPreviewTouchMove(TouchEventArgs)

    protected override void OnPreviewTouchMove(TouchEventArgs args)
    Parameters
    Type Name Description
    TouchEventArgs args
    Overrides
    UIElement.OnPreviewTouchMove(TouchEventArgs)

    OnPreviewTouchUp(TouchEventArgs)

    protected override void OnPreviewTouchUp(TouchEventArgs args)
    Parameters
    Type Name Description
    TouchEventArgs args
    Overrides
    UIElement.OnPreviewTouchUp(TouchEventArgs)

    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
    UIElement.OnTouchEnter(TouchEventArgs)

    OnTouchLeave(TouchEventArgs)

    protected override void OnTouchLeave(TouchEventArgs args)
    Parameters
    Type Name Description
    TouchEventArgs args
    Overrides
    UIElement.OnTouchLeave(TouchEventArgs)

    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
    UIElement.Update(GameTime)

    UpdateWorldMatrix(ref Matrix, Boolean)

    protected override void UpdateWorldMatrix(ref Matrix parentWorldMatrix, bool parentWorldChanged)
    Parameters
    Type Name Description
    Matrix parentWorldMatrix
    System.Boolean parentWorldChanged
    Overrides
    ContentControl.UpdateWorldMatrix(ref Matrix, Boolean)

    Inherited Members

    ContentControl.ContentArrangeMatrixPropertyKey
    ContentControl.VisualContent
    ContentControl.EnumerateChildren()
    Control.padding
    Control.Padding
    UIElement.InputCategory
    UIElement.PanelCategory
    UIElement.AppearanceCategory
    UIElement.BehaviorCategory
    UIElement.LayoutCategory
    UIElement.MiscCategory
    UIElement.MarginInternal
    UIElement.ArrangeChanged
    UIElement.LocalMatrixChanged
    UIElement.Id
    UIElement.DependencyProperties
    UIElement.LocalMatrix
    UIElement.BackgroundColor
    UIElement.Opacity
    UIElement.Visibility
    UIElement.ClipToBounds
    UIElement.DrawLayerNumber
    UIElement.CanBeHitByUser
    UIElement.Width
    UIElement.Height
    UIElement.Depth
    UIElement.Size
    UIElement.HorizontalAlignment
    UIElement.VerticalAlignment
    UIElement.DepthAlignment
    UIElement.Margin
    UIElement.MinimumWidth
    UIElement.MinimumHeight
    UIElement.MinimumDepth
    UIElement.MaximumWidth
    UIElement.MaximumHeight
    UIElement.MaximumDepth
    UIElement.DefaultWidth
    UIElement.DefaultHeight
    UIElement.DefaultDepth
    UIElement.Name
    UIElement.DesiredSize
    UIElement.DesiredSizeWithMargins
    UIElement.IsArrangeValid
    UIElement.IsMeasureValid
    UIElement.WorldMatrix
    UIElement.DepthBias
    UIElement.LayoutingContext
    UIElement.VisualChildrenCollection
    UIElement.InvalidateArrange()
    UIElement.InvalidateMeasure()
    UIElement.OnNameChanged()
    UIElement.IsHierarchyEnabled
    UIElement.IsVisible
    UIElement.IsCollapsed
    UIElement.Parent
    UIElement.VisualParent
    UIElement.VisualChildren
    UIElement.HitableChildren
    UIElement.RenderOpacity
    UIElement.RenderSize
    UIElement.RenderOffsets
    UIElement.ActualWidth
    UIElement.ActualHeight
    UIElement.ActualDepth
    UIElement.IUIElementChildren.Children
    UIElement.Measure(Vector3)
    UIElement.Arrange(Vector3, Boolean)
    UIElement.CollapseOverride()
    UIElement.PropagateCollapseToChild(UIElement)
    UIElement.FindName(String)
    UIElement.SetParent(UIElement, UIElement)
    UIElement.SetVisualParent(UIElement, UIElement)
    UIElement.Intersects(Ray, Vector3)
    UIElement.IUIElementUpdate.Update(GameTime)
    UIElement.IUIElementUpdate.UpdateWorldMatrix(Matrix, Boolean)
    UIElement.IUIElementUpdate.UpdateElementState(Int32)
    UIElement.CalculateSizeWithThickness(Vector3, Thickness)
    UIElement.CalculateSizeWithoutThickness(Vector3, Thickness)
    UIElement.CalculateAdjustmentOffsets(Thickness, Vector3, Vector3)
    UIElement.IsTouched
    UIElement.MouseOverState
    UIElement.RequiresMouseOverUpdate
    UIElement.RaiseEvent(RoutedEventArgs)
    UIElement.AddHandler<T>(RoutedEvent<T>, EventHandler<T>, Boolean)
    UIElement.RemoveHandler<T>(RoutedEvent<T>, EventHandler<T>)
    UIElement.MouseOverStateChanged
    UIElement.PreviewTouchDown
    UIElement.PreviewTouchMove
    UIElement.PreviewTouchUp
    UIElement.TouchDown
    UIElement.TouchEnter
    UIElement.TouchLeave
    UIElement.TouchMove
    UIElement.TouchUp
    UIElement.OnTouchDown(TouchEventArgs)
    UIElement.OnTouchMove(TouchEventArgs)
    UIElement.OnTouchUp(TouchEventArgs)

    Extension Methods

    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    UIElementExtensions.SetPanelZIndex(UIElement, Int32)
    UIElementExtensions.GetPanelZIndex(UIElement)
    UIElementExtensions.SetCanvasRelativeSize(UIElement, Vector3)
    UIElementExtensions.GetCanvasRelativeSize(UIElement)
    UIElementExtensions.SetCanvasRelativePosition(UIElement, Vector3)
    UIElementExtensions.GetCanvasRelativePosition(UIElement)
    UIElementExtensions.SetCanvasAbsolutePosition(UIElement, Vector3)
    UIElementExtensions.GetCanvasAbsolutePosition(UIElement)
    UIElementExtensions.SetCanvasPinOrigin(UIElement, Vector3)
    UIElementExtensions.GetCanvasPinOrigin(UIElement)
    UIElementExtensions.SetGridColumn(UIElement, Int32)
    UIElementExtensions.GetGridColumn(UIElement)
    UIElementExtensions.SetGridRow(UIElement, Int32)
    UIElementExtensions.GetGridRow(UIElement)
    UIElementExtensions.SetGridLayer(UIElement, Int32)
    UIElementExtensions.GetGridLayer(UIElement)
    UIElementExtensions.SetGridColumnSpan(UIElement, Int32)
    UIElementExtensions.GetGridColumnSpan(UIElement)
    UIElementExtensions.SetGridRowSpan(UIElement, Int32)
    UIElementExtensions.GetGridRowSpan(UIElement)
    UIElementExtensions.SetGridLayerSpan(UIElement, Int32)
    UIElementExtensions.GetGridLayerSpan(UIElement)
    VisualTreeHelper.FindVisualChildOfType<T>(UIElement, String)
    VisualTreeHelper.FindVisualChildrenOfType<T>(UIElement)
    VisualTreeHelper.FindVisualParentOfType<T>(UIElement)
    VisualTreeHelper.FindVisualRoot(UIElement)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation