【.Net6】【C1】C1ScrollViewer和ScrollViewerScrollBar怎么自定义Template
本帖最后由 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>
Richard.Ma 发表于 2022-5-20 09:21
问题已经收到,验证后给你回复
这个提错专区了,和另一个帖子是一样的https://gcdn.grapecity.com.cn/forum.php?mod=viewthread&tid=147237&page=1#pid541386 问题已经收到,验证后给你回复 好的,已经在新帖中回复了,这个控件目前没有办法自定义
页:
[1]