WPF,滚动条拇指向后显示
我按照教程从该站点创建滚动条模板: http://sachabarber.net/?p=122< /a>
但由于某种原因,拇指控件向后,当滚动查看器的内容位于顶部时,拇指在底部,当我单击底部重复按钮时,滚动查看器中的内容正确滚动,但是拇指进入这向上方向。反之亦然,当我单击顶部的重复按钮时,拇指会向下移动。
不确定我做了什么才能做到这一点...当我删除我创建的控件模板时,它会返回到默认样式并且拇指已正确放置。
以下是控件模板的代码。我有这个引用滚动条控件的模板,除了拇指之外,所有内容都显示良好。
<ControlTemplate x:Key="kd_VertScrollBar" TargetType="{x:Type ScrollBar}">
<Grid Width="15">
<Grid.RowDefinitions>
<RowDefinition MaxHeight="25"/>
<RowDefinition Height=".00001*"/>
<RowDefinition MaxHeight="25"/>
</Grid.RowDefinitions>
<Border Grid.RowSpan="3" CornerRadius="2" Background="#CCCCCCCC" />
<RepeatButton Grid.Row="0"
Background="Aqua"
Height="25"
ContentTemplate="{StaticResource RepeatButtonImage}"
Command="ScrollBar.LineUpCommand" />
<Track Grid.Row="1">
<Track.DecreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageUpCommand" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource ScrollBarThumb}" Background="Blue" BorderBrush="Black" />
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageDownCommand" />
</Track.IncreaseRepeatButton>
</Track>
<RepeatButton x:Name="ToBottom" Grid.Row="2"
Background="Aqua"
Height="25"
ContentTemplate="{StaticResource RepeatButtonImage}"
Command="ScrollBar.LineDownCommand" />
</Grid>
</ControlTemplate>
任何帮助将不胜感激
I followed a tutorial to create a scrollbar template from this site: http://sachabarber.net/?p=122
But some reason, the Thumb control is backwards, When the content of the scrollviewer is at the top, the thumb as at the bottom, when I click the bottom repeat button thecontent in the scrollviewer scrolls properly, however the thumb goes in the up direction. and vice versa, when I click the top repeat button the thumb goes down.
Not sure what I did to make it do this...When I remove the control template I created, it goes back to the default style and the thumb is properly placed.
Below is the code for the control template. I have this template referenced to Scrollbar control and everything displays fine except for the thumb.
<ControlTemplate x:Key="kd_VertScrollBar" TargetType="{x:Type ScrollBar}">
<Grid Width="15">
<Grid.RowDefinitions>
<RowDefinition MaxHeight="25"/>
<RowDefinition Height=".00001*"/>
<RowDefinition MaxHeight="25"/>
</Grid.RowDefinitions>
<Border Grid.RowSpan="3" CornerRadius="2" Background="#CCCCCCCC" />
<RepeatButton Grid.Row="0"
Background="Aqua"
Height="25"
ContentTemplate="{StaticResource RepeatButtonImage}"
Command="ScrollBar.LineUpCommand" />
<Track Grid.Row="1">
<Track.DecreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageUpCommand" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource ScrollBarThumb}" Background="Blue" BorderBrush="Black" />
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageDownCommand" />
</Track.IncreaseRepeatButton>
</Track>
<RepeatButton x:Name="ToBottom" Grid.Row="2"
Background="Aqua"
Height="25"
ContentTemplate="{StaticResource RepeatButtonImage}"
Command="ScrollBar.LineDownCommand" />
</Grid>
</ControlTemplate>
Any help would be greatly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须设置
IsDirectionReversedTrack
上的 code> 更改为true
,这是默认模板的作用。You must set
IsDirectionReversed
totrue
on theTrack
, which is what the default templates does.