找回密码
 立即注册

QQ登录

只需一步,快速开始

dddsssssqq

注册会员

13

主题

40

帖子

115

积分

注册会员

积分
115
dddsssssqq
注册会员   /  发表于:2022-5-20 09:19  /   查看:2063  /  回复:9
1金币
我新建了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>

9 个回复

倒序浏览
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2022-5-20 09:34:56
沙发
收到,这边验证一下给你回复
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2022-5-20 12:08:34
板凳
这个目前没有提供对应的资源文件,也没有办法自定义templete

.NET6控件中,大部分已经提供了资源文件,直接使用或者修改来自定义样式就行,安装最新版本开发包就能看到
在安装文件夹下的路径如下
ComponentOne\WPF Edition\Resources\v6

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
dddsssssqq
注册会员   /  发表于:2022-5-24 10:48:18
地板
本帖最后由 dddsssssqq 于 2022-5-24 10:56 编辑
Richard.Ma 发表于 2022-5-20 12:08
这个目前没有提供对应的资源文件,也没有办法自定义templete

.NET6控件中,大部分已经提供了资源文件, ...

提供的资源文件不太对呀,并不能直接修改GridSelectionLayer类型控件呀\Resources\v6\C1WPFGridControl\XAML\Generic.xaml

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
dddsssssqq
注册会员   /  发表于:2022-5-24 10:51:12
5#
本帖最后由 dddsssssqq 于 2022-5-24 10:54 编辑
dddsssssqq 发表于 2022-5-24 10:48
提供的资源文件不太对呀,并没有找到GridBase类型控件呀\Resources\v6\C1WPFGrid\XAML\Generic.xaml
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml"
    xmlns:core="clr-namespace:C1.WPF.Core;assembly=C1.WPF.Core"
    xmlns:grid="clr-namespace:C1.WPF.Grid;assembly=C1.WPF.Grid"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/C1.WPF.Core;component/themes/Common.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <SolidColorBrush Color="#e0e0e0" x:Key="GridLinesBrush" />

    <Style TargetType="c1:C1GridControl">
        <Setter Property="Background" Value="{StaticResource BaseColorBrush}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}" />
        <Setter Property="GridLinesBrush" Value="{StaticResource GridLinesBrush}" />
        <Setter Property="SelectionAdornerBrush" Value="{StaticResource BaseColorBrush}" />
        <Setter Property="SelectionAdornerBorderBrush" Value="{StaticResource ForegroundBrushColor}" />
        <Setter Property="CellStyle">
            <Setter.Value>
                <Style TargetType="c1:GridControlCellView">
                    <Setter Property="Background" Value="Transparent" />
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="SelectionStyle">
            <Setter.Value>
                <Style TargetType="c1:GridControlCellView">
                    <Setter Property="SelectedBrush" Value="{StaticResource SelectedBackground}" />
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="MouseOverBrush" Value="{StaticResource MouseOverBrush}" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="EditorBackground" Value="{StaticResource BaseColorBrush}" />
        <Setter Property="EditorForeground" Value="{StaticResource ForegroundBrushColor}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="c1:C1GridControl">
                    <core:C1Border
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        CornerRadius="{TemplateBinding CornerRadius}">
                        <Grid>
                            <core:C1ScrollViewer x:Name="ScrollViewer" />
                            <c1:GridSelectionLayer x:Name="SelectionLayer" />
                            <c1:GridManipulationLayer x:Name="ManipulationLayer" />
                        </Grid>
                    </core:C1Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="c1:GridControlCellView">
        <Setter Property="SnapsToDevicePixels" Value="True" />
    </Style>

</ResourceDictionary>
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2022-5-24 11:42:47
6#
这个C1ScrollViewer目前没有提供资源文件,我上面也和你说过了,目前没法修改

发的目录截图是说其他的C1控件,如果有提供资源文件的话,你可以使用来修改外观
回复 使用道具 举报
dddsssssqq
注册会员   /  发表于:2022-5-24 11:54:17
7#
Richard.Ma 发表于 2022-5-24 11:42
这个C1ScrollViewer目前没有提供资源文件,我上面也和你说过了,目前没法修改

发的目录截图是说其他的C1 ...

这是FlexGrid的。是完全复制安装路径下的Resource内容。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2022-5-24 14:42:27
8#
这个不是flexgrid的,flexgrid是在C1WPFGrid中


你现在具体是用的什么控件?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
dddsssssqq
注册会员   /  发表于:2022-5-24 15:02:21
9#
Richard.Ma 发表于 2022-5-24 14:42
这个不是flexgrid的,flexgrid是在C1WPFGrid中

现在用的是FlexGrid,需要修改滚动条的样式,所以往上就看了C1ScrollViewer和ScrollViewerScrollBar。你可以看下这个ComponentOne的安装目录下提供的文件\ComponentOne\WPF Edition\Resources\v6\C1WPFGrid\XAML\Generic.xaml,这里提供了修改FlexGrid的Template的示例,他是继承了C1GridControl的Style,但是C1GridControl的style用到了两个internal的类,是不是文件有误


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2022-5-24 17:40:01
10#
这个问题我再调研一下给你回复吧,帖子暂时保留处理
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部