ScrollBar 的 ControlTemplate 仅适用于 DataGrid
您好,我有一个 ScrollBar 模板,如下所示 - 仅显示相关部分:
<ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition MaxHeight="18"/>
<RowDefinition Height="0.00001*"/>
<RowDefinition MaxHeight="18"/>
</Grid.RowDefinitions>
<Rectangle Height="35" Width="19" Fill="{StaticResource GreenTeaBrush}" Margin="-35" VerticalAlignment="Top"/>
<Border....
现在是矩形部分:
<Rectangle Height="35" Width="19" Fill="{StaticResource GreenTeaBrush}" Margin="-35" VerticalAlignment="Top"/>
我只希望它显示在 DataGrid 上,或者我希望输入 ControlTemplate 仅适用于 DataGrid 的 ScrollBar。
任何帮助将不胜感激!谢谢!
Hello I have a ScrollBar Template as per below - only relevant portion shown:
<ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition MaxHeight="18"/>
<RowDefinition Height="0.00001*"/>
<RowDefinition MaxHeight="18"/>
</Grid.RowDefinitions>
<Rectangle Height="35" Width="19" Fill="{StaticResource GreenTeaBrush}" Margin="-35" VerticalAlignment="Top"/>
<Border....
Now the Rectangle Portion:
<Rectangle Height="35" Width="19" Fill="{StaticResource GreenTeaBrush}" Margin="-35" VerticalAlignment="Top"/>
I only want that to show up on DataGrids OR i would like this enter ControlTemplate to only work on the ScrollBars of DataGrids.
Any help would be greatly appreciated! Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以嵌套样式,以下样式隐式应用于 DataGrid,它包含 ScrollBars 的样式,该样式也隐式应用:
You can nest Styles, the following style is implicitly applied to DataGrids, it contains a style for ScrollBars which is also applied implicitly: