高度"/>
scrollbar wpf 高度
如何:自訂 ScrollBar 上捲動方塊的大小How to: Customize the Thumb Size on a ScrollBar
03/30/2017
本文內容
本主題說明如何將設定 Thumb ScrollBar 為固定大小,以及如何指定的最小大小 Thumb ScrollBar 。This topic explains how to set the Thumb of a ScrollBar to a fixed size and how to specify a minimum size for the Thumb of a ScrollBar.
範例Example
描述Description
下列範例 ScrollBar 會建立具有 Thumb 固定大小的。The following example creates a ScrollBar that has a Thumb with a fixed size. The example sets the ViewportSize property of the Thumb to NaN and sets the height of the Thumb. 若要建立 ScrollBar Thumb 具有固定寬度的水準,請設定的寬度 Thumb 。To create a horizontal ScrollBar with a Thumb that has a fixed width, set the width of the Thumb.
程式碼Code
Background="{TemplateBinding Background}"
SnapsToDevicePixels="true">
IsEnabled="{TemplateBinding IsMouseOver}"
Height="18"
Command="ScrollBar.LineUpCommand"
Content="M 0 4 L 8 4 L 4 0 Z" />
ViewportSize="NaN"
IsDirectionReversed="true"
Grid.Row="1"
Grid.ZIndex="-1">
Command="ScrollBar.PageUpCommand"/>
Command="ScrollBar.PageDownCommand"/>
Grid.Row="2"
Style="{StaticResource ScrollBarButton}"
Height="18"
Command="ScrollBar.LineDownCommand"
Content="M 0 0 L 4 4 L 8 0 Z"/>
描述Description
下列範例 ScrollBar 會建立具有 Thumb 最小大小的。The following example creates a ScrollBar that has a Thumb with a minimum size. To create a horizontal ScrollBar with a Thumb that has a minimum width, set the HorizontalScrollBarButtonWidthKey.
程式碼Code
Background="{TemplateBinding Background}"
SnapsToDevicePixels="true">
IsEnabled="{TemplateBinding IsMouseOver}"
Height="18"
Command="ScrollBar.LineUpCommand"
Content="M 0 4 L 8 4 L 4 0 Z" />
IsDirectionReversed="true"
Grid.Row="1"
Grid.ZIndex="-1">
x:Key="{x:Static SystemParameters.VerticalScrollBarButtonHeightKey}">
100
Command="ScrollBar.PageUpCommand"/>
Command="ScrollBar.PageDownCommand"/>
Grid.Row="2"
Style="{StaticResource ScrollBarButton}"
Height="18"
Command="ScrollBar.LineDownCommand"
Content="M 0 0 L 4 4 L 8 0 Z"/>
Property="IsEnabled" Value="false">
Property="Visibility" Value="Hidden"/>
另請參閱See also
更多推荐
scrollbar wpf 高度
发布评论