2025-08-24 13:49:55 +08:00
|
|
|
<ResourceDictionary
|
|
|
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
2026-01-02 17:30:41 +08:00
|
|
|
xmlns:assists="clr-namespace:Melskin.Assists"
|
|
|
|
|
xmlns:controls="clr-namespace:Melskin.Controls"
|
2026-01-02 17:30:30 +08:00
|
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
2025-08-24 13:49:55 +08:00
|
|
|
|
|
|
|
|
<Style TargetType="{x:Type controls:TreeGrid}">
|
|
|
|
|
<Setter Property="Background" Value="{DynamicResource BackgroundLayoutBrush}" />
|
|
|
|
|
<Setter Property="assists:ControlAssist.CornerRadius" Value="4" />
|
|
|
|
|
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
|
|
|
|
|
<Setter Property="BorderThickness" Value="1" />
|
|
|
|
|
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
|
|
|
|
<Setter Property="Template">
|
|
|
|
|
<Setter.Value>
|
|
|
|
|
<ControlTemplate TargetType="{x:Type controls:TreeGrid}">
|
2025-12-23 21:35:54 +08:00
|
|
|
<Grid>
|
|
|
|
|
<Border Background="{TemplateBinding Background}" CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}">
|
|
|
|
|
<Border.OpacityMask>
|
|
|
|
|
<VisualBrush>
|
|
|
|
|
<VisualBrush.Visual>
|
|
|
|
|
<!-- 定义遮罩形状:黑色代表可见区域,圆角与外部一致 -->
|
|
|
|
|
<Border
|
|
|
|
|
Background="Black"
|
|
|
|
|
CornerRadius="{Binding CornerRadius, RelativeSource={RelativeSource AncestorType=Border}}"
|
2026-01-02 17:30:30 +08:00
|
|
|
Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType=Border}}"
|
|
|
|
|
SnapsToDevicePixels="True"
|
|
|
|
|
Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=Border}}" />
|
2025-12-23 21:35:54 +08:00
|
|
|
</VisualBrush.Visual>
|
|
|
|
|
</VisualBrush>
|
|
|
|
|
</Border.OpacityMask>
|
|
|
|
|
<DockPanel>
|
|
|
|
|
<!-- 1. 表头区域,放置在顶部 -->
|
|
|
|
|
<!-- - 用 ScrollViewer 包裹以同步滚动 -->
|
|
|
|
|
<!-- - 隐藏自己的滚动条,因为它只是一个“跟随者” -->
|
|
|
|
|
<ScrollViewer
|
|
|
|
|
Background="Transparent"
|
|
|
|
|
DockPanel.Dock="Top"
|
|
|
|
|
HorizontalScrollBarVisibility="Hidden"
|
2026-01-02 17:30:30 +08:00
|
|
|
VerticalScrollBarVisibility="Disabled"
|
|
|
|
|
x:Name="PART_HeaderScrollViewer">
|
2025-12-23 21:35:54 +08:00
|
|
|
<GridViewHeaderRowPresenter Columns="{Binding Columns, RelativeSource={RelativeSource TemplatedParent}}" />
|
|
|
|
|
</ScrollViewer>
|
|
|
|
|
|
|
|
|
|
<!-- 2. 内容区域,占据剩余空间 -->
|
|
|
|
|
<!-- - 将所有相关属性从外层 TreeGrid 传递给内部的 TreeView -->
|
|
|
|
|
<TreeView
|
|
|
|
|
Background="{DynamicResource ControlBackgroundNormalBrush}"
|
|
|
|
|
BorderThickness="0"
|
|
|
|
|
ItemContainerStyle="{Binding ItemContainerStyle, RelativeSource={RelativeSource TemplatedParent}}"
|
|
|
|
|
ItemTemplate="{Binding ItemTemplate, RelativeSource={RelativeSource TemplatedParent}}"
|
2026-01-02 17:30:30 +08:00
|
|
|
ItemsSource="{Binding ItemsSource, RelativeSource={RelativeSource TemplatedParent}}"
|
|
|
|
|
assists:ControlAssist.CornerRadius="0"
|
|
|
|
|
x:Name="PART_ContentTreeView">
|
2025-12-23 21:35:54 +08:00
|
|
|
<!-- 可选:为了性能,可以启用虚拟化 -->
|
|
|
|
|
<TreeView.ItemsPanel>
|
|
|
|
|
<ItemsPanelTemplate>
|
|
|
|
|
<VirtualizingStackPanel />
|
|
|
|
|
</ItemsPanelTemplate>
|
|
|
|
|
</TreeView.ItemsPanel>
|
|
|
|
|
</TreeView>
|
|
|
|
|
</DockPanel>
|
|
|
|
|
</Border>
|
|
|
|
|
<Border
|
2025-08-24 13:49:55 +08:00
|
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
2025-12-23 21:35:54 +08:00
|
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
2025-08-24 13:49:55 +08:00
|
|
|
CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}"
|
2025-12-23 21:35:54 +08:00
|
|
|
IsHitTestVisible="False" />
|
|
|
|
|
</Grid>
|
2025-08-24 13:49:55 +08:00
|
|
|
</ControlTemplate>
|
|
|
|
|
</Setter.Value>
|
|
|
|
|
</Setter>
|
|
|
|
|
</Style>
|
|
|
|
|
</ResourceDictionary>
|