Java中iscroll属性,ScrollViewer.CanContentScroll 属性 (System.Windows.Controls) | Microsoft Docs

获取或设置一个值,该值指示是否允许滚动支持 IScrollInfo 接口的元素。Gets or sets a value that indicates whether elements that support the IScrollInfo interface are allowed to scroll.

public:

property bool CanContentScroll { bool get(); void set(bool value); };

public bool CanContentScroll { get; set; }

member this.CanContentScroll : bool with get, set

Public Property CanContentScroll As Boolean

属性值

true(如果 ScrollViewer 按逻辑单位滚动);false(如果 ScrollViewer 按物理单位滚动),true if the ScrollViewer scrolls in terms of logical units; false if the ScrollViewer scrolls in terms of physical units. 默认值为 false。The default is false.

示例

下面的示例演示如何 CanContentScroll 使用代码设置属性。The following example demonstrates how to set the CanContentScroll property by using code.

private void scrollTrue(object sender, RoutedEventArgs e)

{

svrContent.CanContentScroll = true;

svrContent.Height = 600;

myStackPanel.Visibility = Visibility.Visible;

btnEnableContentScrolling.Visibility = Visibility.Collapsed;

}Private Sub scrollTrue(ByVal sender As Object, ByVal args As RoutedEventArgs)

sv1.CanContentScroll = True

sv1.Height = 600

myStackPanel.Visibility = Visibility.Visible

btn1.Visibility = Visibility.Collapsed

End Sub

注解

中的内容 ScrollViewer 可以根据物理单元或逻辑单元进行滚动。Content in a ScrollViewer can be scrolled in terms of physical units or logical units. 物理单元是与设备无关的像素。Physical units are device independent pixels. 逻辑单元用于在中滚动项 ItemsControl 。Logical units are used for scrolling items within an ItemsControl. 的默认行为 ScrollViewer 是使用物理单元滚动其内容。The default behavior of the ScrollViewer is to use physical units to scroll its content. 但是,在设置为的情况下 CanContentScroll true ,内容可以使用逻辑单元进行滚动。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.

如果需要物理滚动而不是逻辑滚动,请 Panel 在中包装主机元素, ScrollViewer 并将其 CanContentScroll 属性设置为 false 。If you require physical scrolling instead of logical scrolling, wrap the host Panel element in a ScrollViewer and set its CanContentScroll property to false. 物理滚动是大多数元素的默认滚动行为 Panel 。Physical scrolling is the default scroll behavior for most Panel elements.

依赖项属性信息Dependency Property Information

元数据属性设置为 trueMetadata properties set to true

无None

适用于

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值