ScrollContentPresenter.CanContentScroll 属性

定义

指示如果内容支持 IScrollInfo,则是否应当允许内容控制滚动。

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

属性值

Boolean

如果允许内容滚动,则为 true;否则为 falsefalse 值指示将 ScrollContentPresenter 作为滚动工作区。 此属性没有默认值。

示例

以下示例演示如何在可扩展应用程序标记语言 (XAML) 中使用 CanContentScroll 属性。

     <Style TargetType="{x:Type ScrollViewer}">
       <Setter Property="OverridesDefaultStyle" Value="True" />
       <Setter Property="Template">
         <Setter.Value>
           <ControlTemplate TargetType="{x:Type ScrollViewer}">
             <Grid>
               <Grid.ColumnDefinitions>
                 <ColumnDefinition Width="Auto"/>
                 <ColumnDefinition Width="*"/>
               </Grid.ColumnDefinitions>
               <Grid.RowDefinitions>
                 <RowDefinition Height="*"/>
                 <RowDefinition Height="Auto"/>
               </Grid.RowDefinitions>
               <Border Grid.Row="0" Grid.Column="1">
                 <ScrollContentPresenter CanContentScroll="True" Content="{TemplateBinding ScrollViewer.Content}" />
               </Border>
               <ScrollBar Orientation="Vertical" Grid.Row="0" Grid.Column="0" Minimum="0" Maximum="{TemplateBinding ScrollViewer.ScrollableHeight}" Value="{TemplateBinding ScrollViewer.VerticalOffset}" ViewportSize="{TemplateBinding ScrollViewer.ViewportHeight}" Name="PART_VerticalScrollBar" Visibility="{TemplateBinding ScrollViewer.ComputedVerticalScrollBarVisibility}" 
/>
               <ScrollBar Orientation="Horizontal" Grid.Row="1" Grid.Column="1" Minimum="0" Maximum="{TemplateBinding ScrollViewer.ScrollableWidth}" Value="{TemplateBinding ScrollViewer.HorizontalOffset}" ViewportSize="{TemplateBinding ScrollViewer.ViewportWidth}" Name="PART_HorizontalScrollBar" Visibility="{TemplateBinding ScrollViewer.ComputedHorizontalScrollBarVisibility}"/>
             </Grid>
           </ControlTemplate>
         </Setter.Value>
       </Setter>
     </Style>

注解

依赖项属性信息

标识符字段 CanContentScrollProperty
元数据属性设置为 true

适用于