Files
Shrlalgo.RvKits/NeuWPF/NeoUI/Controls/Anchor.xaml
2025-08-20 12:10:13 +08:00

97 lines
5.1 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:NeumUI.Controls"
xmlns:svd="clr-namespace:NeumUI.Controls.Decorations"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- ListBoxItem 的样式保持不变,因为我们内部还是用 ListBox 来显示锚点 -->
<Style TargetType="{x:Type ListBoxItem}" x:Key="AnchorItemStyle">
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="Background" Value="{DynamicResource BackgroundLayoutBrush}" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Height" Value="40" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<!-- <Setter Property="Margin" Value="15" /> -->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid>
<svd:SlotBorder
Background="Transparent"
ClipToBounds="True"
HorizontalAlignment="Stretch"
Intensity="0"
ShaderEnabled="False"
x:Name="slot">
<ContentPresenter
HorizontalAlignment="Center"
TextElement.FontWeight="Normal"
TextElement.Foreground="{DynamicResource TextDisabledBrush}"
VerticalAlignment="Center"
x:Name="content" />
</svd:SlotBorder>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="TextElement.Foreground" TargetName="content" Value="{DynamicResource PrimaryFocusedBrush}" />
<Setter Property="Intensity" TargetName="slot" Value="0.15" />
<Setter Property="ShaderEnabled" TargetName="slot" Value="True" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<!-- <Setter TargetName="ConvexShadow" Property="Background" Value="Transparent" /> -->
<Setter Property="Intensity" TargetName="slot" Value="0.6" />
<Setter Property="ShaderEnabled" TargetName="slot" Value="True" />
<Setter Property="TextElement.FontWeight" TargetName="content" Value="Bold" />
<Setter Property="TextElement.Foreground" TargetName="content" Value="{DynamicResource PrimaryGradientBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Anchor样式和模板 -->
<Style TargetType="{x:Type controls:Anchor}">
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="Background" Value="{DynamicResource BackgroundLayoutBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:Anchor}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- 左侧: 锚点列表 -->
<svd:EmbossBorder
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
ClipToBounds="True"
HorizontalAlignment="Stretch"
Intensity="0">
<ListBox
Background="Transparent"
BorderThickness="0"
Grid.Column="0"
ItemContainerStyle="{StaticResource AnchorItemStyle}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
x:Name="PART_AnchorList" />
</svd:EmbossBorder>
<!-- 右侧: 内容滚动区 -->
<ScrollViewer
Grid.Column="1"
VerticalScrollBarVisibility="Auto"
x:Name="PART_ContentScroller">
<!-- ContentPresenter 会将 Anchor 的 Content 放置在这里 -->
<ContentPresenter />
</ScrollViewer>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>