Files
ShrlAlgoToolkit/NeuWPF/NeoUI/Controls/Anchor.xaml
ShrlAlgo 955a01f564 整理
2025-08-20 12:10:35 +08:00

99 lines
5.2 KiB
XML

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