Table of Contents

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

stylesheet Stylesheet

The stylesheet to use for applying the style.

styleName string

The 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

styleName string

The 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

bool

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

bool

Content

Gets or sets the widget to display in the scroll viewer.

[Browsable(false)]
public override Widget Content { get; set; }

Property Value

Widget

Desktop

Gets or sets the desktop that manages this scroll viewer.

public override Desktop Desktop { get; }

Property Value

Desktop

HorizontalAlignment

Gets or sets the horizontal alignment of the scroll viewer within its parent container.

public override HorizontalAlignment HorizontalAlignment { get; set; }

Property Value

HorizontalAlignment

HorizontalScrollBackground

Gets or sets the image used for the horizontal scrollbar background.

public IImage HorizontalScrollBackground { get; set; }

Property Value

IImage

HorizontalScrollKnob

Gets or sets the image used for the horizontal scrollbar knob (thumb).

public IImage HorizontalScrollKnob { get; set; }

Property Value

IImage

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

int

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

bool

ShowVerticalScrollBar

Gets or sets a value indicating whether the vertical scrollbar is visible.

public bool ShowVerticalScrollBar { get; set; }

Property Value

bool

VerticalAlignment

Gets or sets the vertical alignment of the scroll viewer within its parent container.

public override VerticalAlignment VerticalAlignment { get; set; }

Property Value

VerticalAlignment

VerticalScrollBackground

Gets or sets the image used for the vertical scrollbar background.

public IImage VerticalScrollBackground { get; set; }

Property Value

IImage

VerticalScrollKnob

Gets or sets the image used for the vertical scrollbar knob (thumb).

public IImage VerticalScrollKnob { get; set; }

Property Value

IImage

Methods

ApplyStyle(WidgetStyle)

Applies the specified widget style to this scroll viewer.

protected override void ApplyStyle(WidgetStyle style)

Parameters

style WidgetStyle

The widget style to apply.

CopyFrom(Widget)

Copies the style and properties from another scroll viewer.

protected override void CopyFrom(Widget w)

Parameters

w Widget

The 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

localPos Point

The 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

availableSize Point

The 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

context RenderContext

The render context used for drawing.

OnMouseWheel(float)

Handles mouse wheel scrolling for vertical scrolling.

public override void OnMouseWheel(float delta)

Parameters

delta float

The 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()