Export (0) Print
Expand All

ScrollViewer.CanContentScroll Property

Gets or sets a value that indicates whether elements that support the IScrollInfo interface are allowed to scroll.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public bool CanContentScroll { get; set; }
<object CanContentScroll="bool" .../>

Property Value

Type: System.Boolean
true if the ScrollViewer scrolls in terms of logical units; false if the ScrollViewer scrolls in terms of physical units. The default is false.

Identifier field

CanContentScrollProperty

Metadata properties set to true

None

Content in a ScrollViewer can be scrolled in terms of physical units or logical units. Physical units are device independent pixels. Logical units are used for scrolling items within an ItemsControl. The default behavior of the ScrollViewer is to use physical units to scroll its content. However, in cases where the CanContentScroll is set to true, the content could use logical units to scroll. For example, ListBox, ListView, and other controls that inherit from ItemsControl use logical units to scroll. If CanContentScroll is true, the values of the ExtentHeight, ScrollableHeight, ViewportHeight, and VerticalOffset properties are number of items, instead of physical units.

If you require physical scrolling instead of logical scrolling, wrap the host Panel element in a ScrollViewer and set its CanContentScroll property to false. Physical scrolling is the default scroll behavior for most Panel elements.

The following example demonstrates how to set the CanContentScroll property by using code.


private void scrollTrue(object sender, RoutedEventArgs e)
{
    sv1.CanContentScroll = true;
    sv1.Height = 600;
    myStackPanel.Visibility = Visibility.Visible;
    btn1.Visibility = Visibility.Collapsed;
}


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft