找回密码
 立即注册

QQ登录

只需一步,快速开始

dddsssssqq

注册会员

13

主题

40

帖子

115

积分

注册会员

积分
115
dddsssssqq
注册会员   /  发表于:2022-5-19 19:32  /   查看:1516  /  回复:3
1金币
本帖最后由 dddsssssqq 于 2022-5-19 19:34 编辑

我新建了ControlTemplate,但是不生效
通过style设置ScrollViewerScrollBar的template也失败

<Grid Grid.Column="0">
    <Grid.Resources>

        <ControlTemplate TargetType="{x:Type c1:C1ScrollViewer}" x:Key="c1">
            <Border
                Background="Transparent"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                CornerRadius="{TemplateBinding c1:ClearStyleExtensions.CornerRadius}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <Grid Clip="{Binding Output, ElementName=contentPresenterClip}">
                        <ScrollContentPresenter
                            CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}"
                            ContentTemplate="{TemplateBinding ContentTemplate}"
                            Cursor="{TemplateBinding Cursor}"
                            Margin="{TemplateBinding Padding}"
                            x:Name="PART_ScrollContentPresenter" />
                    </Grid>
                    <ScrollBar
                        Grid.Column="1"
                        Grid.Row="0"
                        IsTabStop="False"
                        Maximum="{TemplateBinding ScrollViewer.ScrollableHeight}"
                        Minimum="0"
                        Orientation="Vertical"
                      Background="Red"
                        Value="{TemplateBinding ScrollViewer.VerticalOffset}"
                        ViewportSize="{TemplateBinding ScrollViewer.ViewportHeight}"
                        Visibility="{TemplateBinding ScrollViewer.ComputedVerticalScrollBarVisibility}"
                        Width="108"
                        x:Name="PART_VerticalScrollBar" />
                    <ScrollBar
                        Grid.Column="0"
                        Grid.Row="1"
                        Height="108"
                        IsTabStop="False"
                        Maximum="{TemplateBinding ScrollViewer.ScrollableWidth}"
                        Minimum="0"
                        Orientation="Horizontal"
                        Style="{TemplateBinding c1:ClearStyleExtensions.ScrollBarStyle}"
                        Value="{TemplateBinding ScrollViewer.HorizontalOffset}"
                        ViewportSize="{TemplateBinding ScrollViewer.ViewportWidth}"
                        Visibility="{TemplateBinding ScrollViewer.ComputedHorizontalScrollBarVisibility}"
                        x:Name="PART_HorizontalScrollBar" />
                </Grid>
            </Border>

        </ControlTemplate>
    </Grid.Resources>
    <c1:C1ScrollViewer Background="AliceBlue" Template="{StaticResource c1}">
        <StackPanel>
            <StackPanel Orientation="Vertical">
                <Button Background="Transparent" Height="100">1</Button>
                <Button Background="Transparent" Height="100">2</Button>
                <Button Background="Transparent" Height="100">3</Button>
                <Button Background="Transparent" Height="100">4</Button>
                <Button Background="Transparent" Height="100">5</Button>
                <Button Background="Transparent" Height="100">6</Button>
                <Button Background="Transparent" Height="100">7</Button>
                <Button Background="Transparent" Height="100">8</Button>
                <Button Background="Transparent" Height="100">9</Button>
                <Button Background="Transparent" Height="100">11</Button>
                <Button Background="Transparent" Height="100">12</Button>
                <Button Background="Transparent" Height="100">13</Button>
                <Button Background="Transparent" Height="100">14</Button>
                <Button Background="Transparent" Height="100">15</Button>
                <Button Background="Transparent" Height="100">16</Button>
                <Button Background="Transparent" Height="100">17</Button>
                <Button Background="Transparent" Height="100">18</Button>
                <Button Background="Transparent" Height="100">19</Button>
                <Button Background="Transparent" Height="100">21</Button>
                <Button Background="Transparent" Height="100">22</Button>
                <Button Background="Transparent" Height="100">23</Button>
                <Button Background="Transparent" Height="100">24</Button>
                <Button Background="Transparent" Height="100">25</Button>
                <Button Background="Transparent" Height="100">26</Button>
                <Button Background="Transparent" Height="100">27</Button>
                <Button Background="Transparent" Height="100">28</Button>
                <Button Background="Transparent" Height="100">29</Button>
            </StackPanel>
        </StackPanel>
    </c1:C1ScrollViewer>
</Grid>

最佳答案

查看完整内容

这个提错专区了,和另一个帖子是一样的https://gcdn.grapecity.com.cn/forum.php?mod=viewthread&tid=147237&page=1#pid541386

3 个回复

倒序浏览
最佳答案
最佳答案
dddsssssqq
注册会员   /  发表于:2022-5-19 19:32:54
来自 3#
Richard.Ma 发表于 2022-5-20 09:21
问题已经收到,验证后给你回复

这个提错专区了,和另一个帖子是一样的https://gcdn.grapecity.com.cn/forum.php?mod=viewthread&tid=147237&page=1#pid541386
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2022-5-20 09:21:12
2#
问题已经收到,验证后给你回复
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2022-5-20 12:09:28
4#
好的,已经在新帖中回复了,这个控件目前没有办法自定义
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部