Files
ShrlAlgoToolkit/NeoUI/NeoUI/Controls/Anchor.xaml

99 lines
5.2 KiB
Plaintext
Raw Normal View History

2025-08-12 23:08:54 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2025-08-20 12:10:35 +08:00
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:assists="clr-namespace:NeoUI.Assists"
xmlns:controls="clr-namespace:NeoUI.Controls"
xmlns:svd="clr-namespace:NeoUI.Controls.Decorations">
2025-08-12 23:08:54 +08:00
<!-- ListBoxItem 的样式保持不变,因为我们内部还是用 ListBox 来显示锚点 -->
2025-08-20 12:10:35 +08:00
<Style x:Key="AnchorItemStyle" TargetType="{x:Type ListBoxItem}">
2025-08-12 23:08:54 +08:00
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
2025-08-12 23:08:54 +08:00
<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
2025-08-20 12:10:35 +08:00
x:Name="slot"
Margin="-4"
HorizontalAlignment="Stretch"
2025-08-12 23:08:54 +08:00
Background="Transparent"
ClipToBounds="True"
Intensity="0"
2025-08-20 12:10:35 +08:00
ShaderEnabled="False">
2025-08-12 23:08:54 +08:00
<ContentPresenter
2025-08-20 12:10:35 +08:00
x:Name="content"
2025-08-12 23:08:54 +08:00
HorizontalAlignment="Center"
VerticalAlignment="Center"
2025-08-20 12:10:35 +08:00
TextElement.FontWeight="Normal"
2025-08-24 13:49:55 +08:00
TextElement.Foreground="{DynamicResource TextPrimaryBrush}" />
2025-08-12 23:08:54 +08:00
</svd:SlotBorder>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
2025-08-20 12:10:35 +08:00
<Setter TargetName="content" Property="TextElement.Foreground" Value="{DynamicResource PrimaryFocusedBrush}" />
<Setter TargetName="slot" Property="Intensity" Value="0.15" />
<Setter TargetName="slot" Property="ShaderEnabled" Value="True" />
2025-08-12 23:08:54 +08:00
</Trigger>
<Trigger Property="IsSelected" Value="True">
<!-- <Setter TargetName="ConvexShadow" Property="Background" Value="Transparent" /> -->
2025-08-20 12:10:35 +08:00
<Setter TargetName="slot" Property="Intensity" Value="0.6" />
<Setter TargetName="slot" Property="ShaderEnabled" Value="True" />
<Setter TargetName="content" Property="TextElement.FontWeight" Value="Bold" />
<Setter TargetName="content" Property="TextElement.Foreground" Value="{DynamicResource PrimaryGradientBrush}" />
2025-08-12 23:08:54 +08:00
</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
2025-08-20 12:10:35 +08:00
HorizontalAlignment="Stretch"
2025-08-12 23:08:54 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
ClipToBounds="True"
Intensity="0">
<ListBox
2025-08-20 12:10:35 +08:00
x:Name="PART_AnchorList"
Grid.Column="0"
2025-08-12 23:08:54 +08:00
Background="Transparent"
BorderThickness="0"
ItemContainerStyle="{StaticResource AnchorItemStyle}"
2025-08-20 12:10:35 +08:00
ScrollViewer.HorizontalScrollBarVisibility="Disabled" />
2025-08-12 23:08:54 +08:00
</svd:EmbossBorder>
<!-- 右侧: 内容滚动区 -->
<ScrollViewer
2025-08-20 12:10:35 +08:00
x:Name="PART_ContentScroller"
2025-08-12 23:08:54 +08:00
Grid.Column="1"
2025-08-20 12:10:35 +08:00
VerticalScrollBarVisibility="Auto">
2025-08-12 23:08:54 +08:00
<!-- ContentPresenter 会将 Anchor 的 Content 放置在这里 -->
<ContentPresenter />
</ScrollViewer>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>