Skip to end of metadata
Go to start of metadata

Remarks

You use UXScrollViewer to host a single content and facilitate scroll bars when the content exceeded the size of the desired size. UXScrollViewer automatically updates its scroll bar layout when the size of the content changed. It also implements a number of rich UX features and behavior such as consistently revealing scroll bars when the mouse cursor is over the scroll viewer, responsive animation and visual state to indicate dragging, scrolling and more.

The following example shows how to use UXScrollViewer using a simple content scenario.

XAML

The following figure shows the result of the above example.

Working with HorizontalScrollBarVisibility Property and VerticalScrollBarVisibility Property

By default, the vertical scrollbar is always displayed regardless of the content size. In this case, the vertical scroll bar is shown disabled if the content fits the size. You can customize this behavior to automatically display the vertical scollbar only when necessary by setting the VerticalScrollBarVisibility to Auto. The same is true for HorizontalScrollBarVisibility as well.

The scroll bar visibility for both vertical and horizontal direction provides the following options:

  • Disabled
    The scroll bar for the particular direction is disabled. In this mode, the scroll bar will never appear eventhough the content exceeds the desired size.
     
  • Auto
    The scroll bar for the particular direction will appear automatically when the content exceeds the desired size.
     
  • Hidden
    The scroll bar for the particular direction is hidden and never appear eventhough the content exceeds the desired size. In this mode, the scroll bar logic is performed which updates the relevant scrolling properties.
     
  • Visible
    The scroll bar for the particular direction will always be visible regardless of the content size.

The following example shows how to show both scroll bars of the UXScrollViewer only when its content exceeds the desired size.

XAML

Definition

public class UXScrollViewer : ISContentControl, IScrollViewer

Summary

The following table summarizes the members exposed in this class.

Public Constructors

UXScrollViewer Constructor()Initializes a new instance of UXScrollViewer class.

Public Properties

ComputedHorizontalScrollBarVisibilityGets a value that indicates whether the horizontal ScrollBar is visible.
ComputedVerticalScrollBarVisibilityGets a value that indicates whether the vertical ScrollBar is visible.
ExtentHeightGets a value that contains the vertical size of the extent.
ExtentWidthGets a value that contains the horizontal size of the extent.
ForceTabStopGets or sets a value indicating whether the scroll viewer should retain its tab stop behavior.
HorizontalOffsetGets a value that contains the horizontal offset of the scrolled content.
HorizontalScrollBarVisibilityGets or sets a value that indicates whether a horizontal ScrollBar should be displayed.
InternalScrollViewerStyleGets or sets the style to apply to the internal scroll viewer.
ScrollableHeightGets a value that represents the vertical size of the content element that can be scrolled.
ScrollableWidthGets a value that represents the horizontal size of the content element that can be scrolled.
ScrollViewerStyleGets or sets the style to apply to the scroll viewer element.
VerticalOffsetGets a value that contains the vertical offset of the scrolled content.
VerticalScrollBarVisibilityGets or sets a value that indicates whether a vertical ScrollBar should be displayed.
ViewportHeightGets a value that contains the vertical size of the content's viewport.
ViewportWidthGets a value that contains the horizontal size of the content's viewport.

Protected Properties

ProductProduct Info.

Fields

ForceTabStopPropertyIdentifies the ForceTabStop dependency property.
HorizontalScrollBarVisibilityPropertyIdentifies the HorizontalScrollBarVisibility dependency property.
HorizontalScrollEventIdentifies the Horizontal Scroll routed event.
HorizontalValueChangedEventIdentifies the Horizontal Value Changed routed event.
InternalScrollViewerStylePropertyIdentifies the InternalScrollViewerStyle dependency property.
ScrollViewerStylePropertyIdentifies the ScrollViewerStyle dependency property.
VerticalScrollBarVisibilityPropertyIdentifies the VerticalScrollBarVisibility dependency property.
VerticalScrollEventIdentifies the Vertical Scroll routed event.
VerticalValueChangedEventIdentifies the Vertical Value Changed routed event.

Public Methods

AttachEventHandlers()Attach built-in event handlers to control templates. Call this method if necessary.
DetachedEventHandlers()Detach built-in event handlers from control templates. Call this method if necessary.
InitializeTemplates()Initializes control templates.
InvalidateScrollInfo()Invalidates the scroll data of the ScrollViewer.
ScrollToHorizontalOffset(double)Scrolls the content that is within the ScrollViewer to the specified horizontal position.
ScrollToVerticalOffset(double)Scrolls the content that is within the ScrollViewer to the specified vertical position.

Events

HorizontalScrollOccurs when the Value of the horizontal scrollbar changes.
HorizontalValueChangedOccurs when the Value of the horizontal scrollbar changes.
VerticalScrollOccurs when the Value of the vertical scrollbar changes.
VerticalValueChangedOccurs when the Value of the vertical scrollbar changes.

Public Constructors

public UXScrollViewer()

Initializes a new instance of UXScrollViewer class.

Public Properties

public Visibility ComputedHorizontalScrollBarVisibility { get; }

Gets a value that indicates whether the horizontal ScrollBar is visible.

public Visibility ComputedVerticalScrollBarVisibility { get; }

Gets a value that indicates whether the vertical ScrollBar is visible.

public double ExtentHeight { get; }

Gets a value that contains the vertical size of the extent.

public double ExtentWidth { get; }

Gets a value that contains the horizontal size of the extent.

public bool ForceTabStop { get; set; }

Gets or sets a value indicating whether the scroll viewer should retain its tab stop behavior.

public double HorizontalOffset { get; }

Gets a value that contains the horizontal offset of the scrolled content.

public ScrollBarVisibility HorizontalScrollBarVisibility { get; set; }

Gets or sets a value that indicates whether a horizontal ScrollBar should be displayed.

public Style InternalScrollViewerStyle { get; set; }

Gets or sets the style to apply to the internal scroll viewer.

public double ScrollableHeight { get; }

Gets a value that represents the vertical size of the content element that can be scrolled.

public double ScrollableWidth { get; }

Gets a value that represents the horizontal size of the content element that can be scrolled.

public Style ScrollViewerStyle { get; set; }

Gets or sets the style to apply to the scroll viewer element.

public double VerticalOffset { get; }

Gets a value that contains the vertical offset of the scrolled content.

public ScrollBarVisibility VerticalScrollBarVisibility { get; set; }

Gets or sets a value that indicates whether a vertical ScrollBar should be displayed.

public double ViewportHeight { get; }

Gets a value that contains the vertical size of the content's viewport.

public double ViewportWidth { get; }

Gets a value that contains the horizontal size of the content's viewport.

Protected Properties

protected ProductInfo Product { get; }

Product Info.

Fields

public static readonly DependencyProperty ForceTabStopProperty

Identifies the ForceTabStop dependency property.

public static readonly DependencyProperty HorizontalScrollBarVisibilityProperty

Identifies the HorizontalScrollBarVisibility dependency property.

public static readonly RoutedEvent HorizontalScrollEvent

Identifies the Horizontal Scroll routed event.

public static readonly RoutedEvent HorizontalValueChangedEvent

Identifies the Horizontal Value Changed routed event.

public static readonly DependencyProperty InternalScrollViewerStyleProperty

Identifies the InternalScrollViewerStyle dependency property.

public static readonly DependencyProperty ScrollViewerStyleProperty

Identifies the ScrollViewerStyle dependency property.

public static readonly DependencyProperty VerticalScrollBarVisibilityProperty

Identifies the VerticalScrollBarVisibility dependency property.

public static readonly RoutedEvent VerticalScrollEvent

Identifies the Vertical Scroll routed event.

public static readonly RoutedEvent VerticalValueChangedEvent

Identifies the Vertical Value Changed routed event.

Public Methods

public void AttachEventHandlers()

Attach built-in event handlers to control templates. Call this method if necessary.

public void DetachedEventHandlers()

Detach built-in event handlers from control templates. Call this method if necessary.

public void InitializeTemplates()

Initializes control templates.

public void InvalidateScrollInfo()

Invalidates the scroll data of the ScrollViewer.

public void ScrollToHorizontalOffset(double offset)

Scrolls the content that is within the ScrollViewer to the specified horizontal position.

Parameters

offsetThe position that the content scrolls to.

 

public void ScrollToVerticalOffset(double offset)

Scrolls the content that is within the ScrollViewer to the specified vertical position.

Parameters

offsetThe position that the content scrolls to.

 

Events

public event ScrollEventHandler HorizontalScroll

Occurs when the Value of the horizontal scrollbar changes.

public event ValueChangedEventHandler HorizontalValueChanged

Occurs when the Value of the horizontal scrollbar changes.

public event ScrollEventHandler VerticalScroll

Occurs when the Value of the vertical scrollbar changes.

public event ValueChangedEventHandler VerticalValueChanged

Occurs when the Value of the vertical scrollbar changes.

  • No labels