gpt4 book ai didi

c# - WPF:TreeView 或 TreeListView header 水平滚动问题

转载 作者:行者123 更新时间:2023-11-30 12:47:42 24 4
gpt4 key购买 nike

我从 here 下载了 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>

垂直滚动条很好。但问题是 Horizo​​ntal Scolbar。当数据被水平裁剪并且滚动条向右移动时,数据向右移动但标题保持在原处。像这样。

如何解决水平滚动 treeitem 时标题随之移动的问题。我不允许将标题放在 scrollviewer 中,因为当数据垂直滚动时它们需要可见。

最佳答案

如果您希望整个 TreeView (包括标题)水平滚动,另外添加一个 scrolviewer,如下所示:

<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled" >
<Treeview/>
</ScrollViewer>

关于c# - WPF:TreeView 或 TreeListView header 水平滚动问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16162067/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com