WPF-自定义滚动条ScrollBar

来源:转载

滚动条的基本构成。

有了这些,就可以定义自己的滚动条了。

<Style TargetType="{x:Type ScrollBar}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ScrollBar}"> <StackPanel> <!--上按钮--> <RepeatButton HorizontalAlignment="Center" VerticalAlignment="Top" Command="ScrollBar.LineUpCommand" Content="^"/> <Track x:Name="PART_Track" IsDirectionReversed="True" Height="100"> <Track.DecreaseRepeatButton> <!--上空白--> <RepeatButton Command="ScrollBar.PageUpCommand" /> </Track.DecreaseRepeatButton> <Track.Thumb> <!--滑块--> <Thumb Background="Black"/> </Track.Thumb> <Track.IncreaseRepeatButton> <!--下空白--> <RepeatButton Command="ScrollBar.PageDownCommand" /> </Track.IncreaseRepeatButton> </Track> <!--下按钮--> <RepeatButton HorizontalAlignment="Center" VerticalAlignment="Top" Command="ScrollBar.LineDownCommand" Content="v"/> </StackPanel> </ControlTemplate> </Setter.Value> </Setter></Style>

原文地址:http://www.luacloud.com/2011/06/28/wpf-%e8%87%aa%e5%ae%9a%e4%b9%89%e6%bb%9a%e5%8a%a8%e6%9d%a1scrollbar/

分享给朋友:
您可能感兴趣的文章:
随机阅读: