Class ScrollViewer
Represents a scrollable area that can contain other visible elements.
Inheritance
Inherited Members
Namespace: System.Windows.Controls
Assembly: OpenSilver.dll
Syntax
[TemplatePart(Name = "ScrollContentPresenter", Type = typeof(ScrollContentPresenter))]
[TemplatePart(Name = "HorizontalScrollBar", Type = typeof(ScrollBar))]
[TemplatePart(Name = "VerticalScrollBar", Type = typeof(ScrollBar))]
public sealed class ScrollViewer : ContentControl, IControl, IFrameworkElement, IUIElement, IDependencyObject
Constructors
| Improve this Doc View SourceScrollViewer()
Initializes a new instance of the ScrollViewer class.
Declaration
public ScrollViewer()
Fields
| Improve this Doc View SourceComputedHorizontalScrollBarVisibilityProperty
Identifies the ComputedHorizontalScrollBarVisibility dependency property.
Declaration
public static readonly DependencyProperty ComputedHorizontalScrollBarVisibilityProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
ComputedVerticalScrollBarVisibilityProperty
Identifies the ComputedVerticalScrollBarVisibility dependency property.
Declaration
public static readonly DependencyProperty ComputedVerticalScrollBarVisibilityProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
ExtentHeightProperty
Identifier for the ExtentHeight dependency property.
Declaration
public static readonly DependencyProperty ExtentHeightProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
ExtentWidthProperty
Identifier for the ExtentWidth dependency property.
Declaration
public static readonly DependencyProperty ExtentWidthProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
HorizontalOffsetProperty
Identifies the HorizontalOffset dependency property.
Declaration
public static readonly DependencyProperty HorizontalOffsetProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
HorizontalScrollBarVisibilityProperty
Identifies the HorizontalScrollBarVisibility dependency property.
Declaration
public static readonly DependencyProperty HorizontalScrollBarVisibilityProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
ScrollableHeightProperty
Identifies the ScrollableHeight dependency property.
Declaration
public static readonly DependencyProperty ScrollableHeightProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
ScrollableWidthProperty
Identifies the ScrollableWidth dependency property.
Declaration
public static readonly DependencyProperty ScrollableWidthProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
VerticalOffsetProperty
Identifies the VerticalOffset dependency property.
Declaration
public static readonly DependencyProperty VerticalOffsetProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
VerticalScrollBarVisibilityProperty
Identifies the VerticalScrollBarVisibility dependency property.
Declaration
public static readonly DependencyProperty VerticalScrollBarVisibilityProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
ViewportHeightProperty
Identifies the ViewportHeight dependency property.
Declaration
public static readonly DependencyProperty ViewportHeightProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
ViewportWidthProperty
Identifies the ViewportWidth dependency property.
Declaration
public static readonly DependencyProperty ViewportWidthProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
Properties
| Improve this Doc View SourceComputedHorizontalScrollBarVisibility
Gets a value that indicates whether the horizontal ScrollBar is visible.
Declaration
public Visibility ComputedHorizontalScrollBarVisibility { get; }
Property Value
Type | Description |
---|---|
Visibility | A Visibility that indicates whether the horizontal scroll bar is visible. The default value is Visible. |
ComputedVerticalScrollBarVisibility
Gets a value that indicates whether the vertical ScrollBar is visible.
Declaration
public Visibility ComputedVerticalScrollBarVisibility { get; }
Property Value
Type | Description |
---|---|
Visibility | A Visibility that indicates whether the vertical scroll bar is visible. The default value is Visible. |
ExtentHeight
Gets the vertical size of all the content for display in the ScrollViewer.
Declaration
public double ExtentHeight { get; }
Property Value
Type | Description |
---|---|
System.Double | The vertical size of all the content for display in the ScrollViewer. |
ExtentWidth
Gets the horizontal size of all the content for display in the ScrollViewer.
Declaration
public double ExtentWidth { get; }
Property Value
Type | Description |
---|---|
System.Double | The horizontal size of all the content for display in the ScrollViewer. |
HorizontalOffset
Gets a value that contains the horizontal offset of the scrolled content.
Declaration
public double HorizontalOffset { get; }
Property Value
Type | Description |
---|---|
System.Double | The horizontal offset of the scrolled content. The default value is 0.0. |
HorizontalScrollBarVisibility
Gets or sets a value that indicates whether a horizontal ScrollBar should be displayed.
Declaration
public ScrollBarVisibility HorizontalScrollBarVisibility { get; set; }
Property Value
Type | Description |
---|---|
ScrollBarVisibility | A ScrollBarVisibility value that indicates whether a horizontal ScrollBar should be displayed. The default value is Hidden. |
ScrollableHeight
Gets a value that represents the vertical size of the area that can be scrolled; the difference between the height of the extent and the height of the viewport.
Declaration
public double ScrollableHeight { get; }
Property Value
Type | Description |
---|---|
System.Double | The vertical size of the area that can be scrolled. This property has no default value. |
ScrollableWidth
Gets a value that represents the horizontal size of the area that can be scrolled; the difference between the width of the extent and the width of the viewport.
Declaration
public double ScrollableWidth { get; }
Property Value
Type | Description |
---|---|
System.Double | The horizontal size of the area that can be scrolled. This property has no default value. |
VerticalOffset
Gets a value that contains the vertical offset of the scrolled content.
Declaration
public double VerticalOffset { get; }
Property Value
Type | Description |
---|---|
System.Double | The vertical offset of the scrolled content. The default value is 0.0. |
VerticalScrollBarVisibility
Gets or sets a value that indicates whether a vertical ScrollBar should be displayed.
Declaration
public ScrollBarVisibility VerticalScrollBarVisibility { get; set; }
Property Value
Type | Description |
---|---|
ScrollBarVisibility | A ScrollBarVisibility value that indicates whether a vertical ScrollBar should be displayed. The default value is Visible. |
ViewportHeight
Gets a value that contains the vertical size of the viewable content.
Declaration
public double ViewportHeight { get; }
Property Value
Type | Description |
---|---|
System.Double | The vertical size of the viewable content. This property has no default value. |
ViewportWidth
Gets a value that contains the horizontal size of the viewable content.
Declaration
public double ViewportWidth { get; }
Property Value
Type | Description |
---|---|
System.Double | The horizontal size of the viewable content. The default value is 0.0. |
Methods
| Improve this Doc View SourceArrangeOverride(Size)
Declaration
protected override Size ArrangeOverride(Size arrangeSize)
Parameters
Type | Name | Description |
---|---|---|
Size | arrangeSize |
Returns
Type | Description |
---|---|
Size |
Overrides
| Improve this Doc View SourceGetHorizontalScrollBarVisibility(DependencyObject)
Gets the value of the HorizontalScrollBarVisibility dependency property from a specified element.
Declaration
public static ScrollBarVisibility GetHorizontalScrollBarVisibility(DependencyObject element)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | element | The element from which the property value is read. |
Returns
Type | Description |
---|---|
ScrollBarVisibility | The value of the HorizontalScrollBarVisibility dependency property. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
GetVerticalScrollBarVisibility(DependencyObject)
Gets the value of the VerticalScrollBarVisibility dependency property from a specified element.
Declaration
public static ScrollBarVisibility GetVerticalScrollBarVisibility(DependencyObject element)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | element | The element from which the property value is read. |
Returns
Type | Description |
---|---|
ScrollBarVisibility | The value of the VerticalScrollBarVisibility dependency property. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
InvalidateScrollInfo()
Called when the value of properties that describe the size and location of the scroll area change.
Declaration
public void InvalidateScrollInfo()
MeasureOverride(Size)
Declaration
protected override Size MeasureOverride(Size constraint)
Parameters
Type | Name | Description |
---|---|---|
Size | constraint |
Returns
Type | Description |
---|---|
Size |
Overrides
| Improve this Doc View SourceOnApplyTemplate()
Declaration
public override void OnApplyTemplate()
Overrides
| Improve this Doc View SourceOnCreateAutomationPeer()
Declaration
protected override AutomationPeer OnCreateAutomationPeer()
Returns
Type | Description |
---|---|
AutomationPeer |
Overrides
| Improve this Doc View SourceOnKeyDown(KeyEventArgs)
Responds to the KeyDown event.
Declaration
protected override void OnKeyDown(KeyEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
KeyEventArgs | e | Provides data for KeyEventArgs. |
Overrides
| Improve this Doc View SourceOnMouseLeftButtonDown(MouseButtonEventArgs)
Declaration
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseButtonEventArgs | e |
Overrides
| Improve this Doc View SourceOnMouseLeftButtonUp(MouseButtonEventArgs)
Declaration
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseButtonEventArgs | e |
Overrides
| Improve this Doc View SourceOnMouseMove(MouseEventArgs)
Declaration
protected override void OnMouseMove(MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseEventArgs | e |
Overrides
| Improve this Doc View SourceOnMouseWheel(MouseWheelEventArgs)
Declaration
protected override void OnMouseWheel(MouseWheelEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseWheelEventArgs | e |
Overrides
| Improve this Doc View SourceScrollToHorizontalOffset(Double)
Scrolls the content that is within the ScrollViewer to the specified horizontal offset position.
Declaration
public void ScrollToHorizontalOffset(double offset)
Parameters
Type | Name | Description |
---|---|---|
System.Double | offset | The position that the content scrolls to. |
ScrollToVerticalOffset(Double)
Scrolls the content that is within the ScrollViewer to the specified vertical offset position.
Declaration
public void ScrollToVerticalOffset(double offset)
Parameters
Type | Name | Description |
---|---|---|
System.Double | offset | The position that the content scrolls to. |
SetHorizontalScrollBarVisibility(DependencyObject, ScrollBarVisibility)
Sets the value of the HorizontalScrollBarVisibility dependency property to a specified element.
Declaration
public static void SetHorizontalScrollBarVisibility(DependencyObject element, ScrollBarVisibility horizontalScrollBarVisibility)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | element | The element on which to set the property value. |
ScrollBarVisibility | horizontalScrollBarVisibility | The property value to set. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
SetVerticalScrollBarVisibility(DependencyObject, ScrollBarVisibility)
Sets the value of the VerticalScrollBarVisibility dependency property to a specified element.
Declaration
public static void SetVerticalScrollBarVisibility(DependencyObject element, ScrollBarVisibility verticalScrollBarVisibility)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | element | The element on which to set the property value. |
ScrollBarVisibility | verticalScrollBarVisibility | The property value to set. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|