【.Net6】【C1】C1ScrollViewer和ScrollViewerScrollBar怎么自定义Template
我新建了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>
收到,这边验证一下给你回复 这个目前没有提供对应的资源文件,也没有办法自定义templete
.NET6控件中,大部分已经提供了资源文件,直接使用或者修改来自定义样式就行,安装最新版本开发包就能看到
在安装文件夹下的路径如下
ComponentOne\WPF Edition\Resources\v6
本帖最后由 dddsssssqq 于 2022-5-24 10:56 编辑
Richard.Ma 发表于 2022-5-20 12:08
这个目前没有提供对应的资源文件,也没有办法自定义templete
.NET6控件中,大部分已经提供了资源文件, ...
提供的资源文件不太对呀,并不能直接修改GridSelectionLayer类型控件呀\Resources\v6\C1WPFGridControl\XAML\Generic.xaml 本帖最后由 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>
这个C1ScrollViewer目前没有提供资源文件,我上面也和你说过了,目前没法修改
发的目录截图是说其他的C1控件,如果有提供资源文件的话,你可以使用来修改外观 Richard.Ma 发表于 2022-5-24 11:42
这个C1ScrollViewer目前没有提供资源文件,我上面也和你说过了,目前没法修改
发的目录截图是说其他的C1 ...
这是FlexGrid的。是完全复制安装路径下的Resource内容。 这个不是flexgrid的,flexgrid是在C1WPFGrid中
你现在具体是用的什么控件? 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的类,是不是文件有误
这个问题我再调研一下给你回复吧,帖子暂时保留处理
页:
[1]