Class ScrollViewer
- Namespace
- Myra.Graphics2D.UI
- Assembly
- Myra.dll
A container that displays its content with horizontal and/or vertical scrollbars for navigation when content exceeds available space.
public class ScrollViewer : ContentControl, IItemWithId, INotifyAttachedPropertyChanged, IContent
- Inheritance
-
ScrollViewer
- Implements
- Inherited Members
Constructors
ScrollViewer(Stylesheet, string)
Initializes a new instance of the ScrollViewer class with the specified stylesheet and style.
public ScrollViewer(Stylesheet stylesheet, string styleName = "")
Parameters
stylesheetStylesheetThe stylesheet to use for applying the style.
styleNamestringThe name of the style to apply to the scroll viewer.
ScrollViewer(string)
Initializes a new instance of the ScrollViewer class.
public ScrollViewer(string styleName = "")
Parameters
styleNamestringThe name of the style to apply to the scroll viewer.
Properties
AcceptsMouseWheel
Gets a value indicating whether this scroll viewer accepts mouse wheel input for scrolling.
protected override bool AcceptsMouseWheel { get; }
Property Value
ClipToBounds
Gets or sets a value indicating whether content extending beyond the scroll viewer bounds is clipped.
public override bool ClipToBounds { get; set; }
Property Value
Content
Gets or sets the widget to display in the scroll viewer.
[Browsable(false)]
public override Widget Content { get; set; }
Property Value
Desktop
Gets or sets the desktop that manages this scroll viewer.
public override Desktop Desktop { get; }
Property Value
HorizontalAlignment
Gets or sets the horizontal alignment of the scroll viewer within its parent container.
public override HorizontalAlignment HorizontalAlignment { get; set; }
Property Value
HorizontalScrollBackground
Gets or sets the image used for the horizontal scrollbar background.
public IImage HorizontalScrollBackground { get; set; }
Property Value
HorizontalScrollKnob
Gets or sets the image used for the horizontal scrollbar knob (thumb).
public IImage HorizontalScrollKnob { get; set; }
Property Value
ScrollMaximum
Gets the maximum scroll position for horizontal and vertical scrolling.
[Browsable(false)]
public Point ScrollMaximum { get; }
Property Value
- Point
ScrollMultiplier
Gets or sets the multiplier for mouse wheel scrolling speed.
public int ScrollMultiplier { get; set; }
Property Value
ScrollPosition
Gets or sets the current scroll position for both horizontal and vertical scrolling.
[Browsable(false)]
public Point ScrollPosition { get; set; }
Property Value
- Point
ShowHorizontalScrollBar
Gets or sets a value indicating whether the horizontal scrollbar is visible.
public bool ShowHorizontalScrollBar { get; set; }
Property Value
ShowVerticalScrollBar
Gets or sets a value indicating whether the vertical scrollbar is visible.
public bool ShowVerticalScrollBar { get; set; }
Property Value
VerticalAlignment
Gets or sets the vertical alignment of the scroll viewer within its parent container.
public override VerticalAlignment VerticalAlignment { get; set; }
Property Value
VerticalScrollBackground
Gets or sets the image used for the vertical scrollbar background.
public IImage VerticalScrollBackground { get; set; }
Property Value
VerticalScrollKnob
Gets or sets the image used for the vertical scrollbar knob (thumb).
public IImage VerticalScrollKnob { get; set; }
Property Value
Methods
ApplyStyle(WidgetStyle)
Applies the specified widget style to this scroll viewer.
protected override void ApplyStyle(WidgetStyle style)
Parameters
styleWidgetStyleThe widget style to apply.
CopyFrom(Widget)
Copies the style and properties from another scroll viewer.
protected override void CopyFrom(Widget w)
Parameters
wWidgetThe source scroll viewer to copy from.
InputFallsThrough(Point)
Determines whether input at the specified position falls through to elements behind the scroll viewer.
public override bool InputFallsThrough(Point localPos)
Parameters
localPosPointThe position in the scroll viewer's local coordinates.
Returns
- bool
True if the input falls through; otherwise false.
InternalArrange()
Arranges the scroll viewer and its content, including scrollbars.
protected override void InternalArrange()
InternalMeasure(Point)
Measures the size required for the scroll viewer and its content.
protected override Point InternalMeasure(Point availableSize)
Parameters
availableSizePointThe available size for measurement.
Returns
- Point
The measured size including scrollbars if needed.
InternalRender(RenderContext)
Renders the scroll viewer content and scrollbars.
public override void InternalRender(RenderContext context)
Parameters
contextRenderContextThe render context used for drawing.
OnMouseWheel(float)
Handles mouse wheel scrolling for vertical scrolling.
public override void OnMouseWheel(float delta)
Parameters
deltafloatThe mouse wheel delta value.
OnTouchDown()
Handles touch down events on the scroll viewer, including scrollbar interaction.
public override void OnTouchDown()
OnTouchUp()
Handles touch up events on the scroll viewer.
public override void OnTouchUp()
ResetScroll()
Resets the scroll position to the top-left corner.
public void ResetScroll()