WPF,滚动条拇指向后显示

发布于 2024-11-27 12:37:51 字数 2315 浏览 1 评论 0原文

我按照教程从该站点创建滚动条模板: 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无人接听 2024-12-04 12:37:51

您必须设置 IsDirectionReversedTrack 上的 code> 更改为 true,这是默认模板的作用。

You must set IsDirectionReversed to true on the Track, which is what the default templates does.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文