我从这里下载了 TreeListView 。剪切数据时不显示水平或垂直滚动条。像这样
所以我将其样式更改为
<Style TargetType="{x:Type l:TreeListView}">
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility"
Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility"
Value="Auto" />
<Setter Property="VerticalContentAlignment"
Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type l:TreeListView}">
<Border BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<DockPanel>
<GridViewHeaderRowPresenter Columns="{StaticResource gvcc}"
DockPanel.Dock="Top" />
<ScrollViewer x:Name="_tv_scrollviewer_"
Background="{TemplateBinding Background}"
CanContentScroll="False"
Focusable="True"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
<ItemsPresenter />
</ScrollViewer>
</DockPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="VirtualizingStackPanel.IsVirtualizing"
Value="true">
<Setter Property="CanContentScroll"
TargetName="_tv_scrollviewer_"
Value="true" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
垂直滚动条很好。但问题是水平 Scollbar。当数据被水平剪切并且滚动条向右移动时,数据向右移动但标题保持在原位。像这样。
如何克服当treeitem水平滚动时,标题随之移动的问题。我不允许将标题放在滚动查看器中,因为它们需要在垂直滚动数据时可见。