更新窗口的snap layouts和tab样式

This commit is contained in:
GG Z
2025-09-09 21:41:37 +08:00
parent 6ef36a08db
commit a86ed1c670
9 changed files with 199 additions and 75 deletions

View File

@@ -35,21 +35,21 @@ public class WindowAssist
/// 附加属性,用于手动控制控件的视觉状态。 /// 附加属性,用于手动控制控件的视觉状态。
/// XAML中的Triggers将绑定到此属性而不是IsMouseOver或IsPressed。 /// XAML中的Triggers将绑定到此属性而不是IsMouseOver或IsPressed。
/// </summary> /// </summary>
public static readonly DependencyProperty VisualStateProperty = public static readonly DependencyProperty WindowButtonStateProperty =
DependencyProperty.RegisterAttached( DependencyProperty.RegisterAttached(
"VisualState", // 属性名 "WindowButtonState", // 属性名
typeof(WindowButtonState), // 属性类型 (我们定义的枚举) typeof(WindowButtonState), // 属性类型 (我们定义的枚举)
typeof(WindowAssist), // 拥有者类 typeof(WindowAssist), // 拥有者类
new PropertyMetadata(WindowButtonState.Normal)); // 默认值 new PropertyMetadata(WindowButtonState.Normal)); // 默认值
public static WindowButtonState GetVisualState(DependencyObject obj) public static WindowButtonState GetWindowButtonState(DependencyObject obj)
{ {
return (WindowButtonState)obj.GetValue(VisualStateProperty); return (WindowButtonState)obj.GetValue(WindowButtonStateProperty);
} }
public static void SetVisualState(DependencyObject obj, WindowButtonState value) public static void SetWindowButtonState(DependencyObject obj, WindowButtonState value)
{ {
obj.SetValue(VisualStateProperty, value); obj.SetValue(WindowButtonStateProperty, value);
} }
} }

View File

@@ -20,10 +20,8 @@
<StackPanel> <StackPanel>
<ToggleButton <ToggleButton
x:Name="HeaderButton" x:Name="HeaderButton"
Padding="5" Padding="6"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="0,0,0,1"
Content="{TemplateBinding Header}" Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplate="{TemplateBinding HeaderTemplate}"
Cursor="Hand" Cursor="Hand"
@@ -69,6 +67,7 @@
</ControlTemplate> </ControlTemplate>
</ToggleButton.Template> </ToggleButton.Template>
</ToggleButton> </ToggleButton>
<Rectangle Margin="-4,0" x:Name="Divider" Height="1" Fill="{DynamicResource BorderNormalBrush}"/>
<Border <Border
x:Name="ContentSiteWrapper" x:Name="ContentSiteWrapper"
ClipToBounds="True" ClipToBounds="True"

View File

@@ -3,8 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:assists="clr-namespace:NeoUI.Assists" xmlns:assists="clr-namespace:NeoUI.Assists"
xmlns:controls="clr-namespace:NeoUI.Controls" xmlns:controls="clr-namespace:NeoUI.Controls"
xmlns:markup="clr-namespace:NeoUI.Markup" xmlns:converters="clr-namespace:NeoUI.Converters"
xmlns:decorations="clr-namespace:NeoUI.Controls.Decorations"> xmlns:decorations="clr-namespace:NeoUI.Controls.Decorations"
xmlns:markup="clr-namespace:NeoUI.Markup">
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/NeoUI;component/Animations/Animations.xaml" /> <ResourceDictionary Source="/NeoUI;component/Animations/Animations.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
@@ -74,11 +75,85 @@
To="0.5" To="0.5"
Duration="0" /> Duration="0" />
</Storyboard> </Storyboard>
<Style x:Key="IconButton" TargetType="Button">
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="assists:ButtonAssist.Icon" Value="{x:Null}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<decorations:EmbossBorder
x:Name="emboss"
Width="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualHeight}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualHeight, Converter={x:Static converters:DivideByTwoConverter.Instance}}"
Intensity="0.8"
ShaderEnabled="True" />
<decorations:SlotBorder
x:Name="slot"
Width="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualHeight}"
Height="{TemplateBinding Width}"
Margin="0"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualHeight, Converter={x:Static converters:DivideByTwoConverter.Instance}}"
Intensity="0"
ShaderEnabled="False">
<ContentPresenter
x:Name="contentPresenter"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{Binding Path=(assists:ButtonAssist.Icon), RelativeSource={RelativeSource TemplatedParent}}"
Focusable="False"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
TextElement.Foreground="{TemplateBinding Foreground}" />
</decorations:SlotBorder>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Button.IsDefaulted" Value="True" />
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="emboss" Property="Intensity" Value="1" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="emboss" Property="Intensity" Value="0.4" />
<Setter TargetName="slot" Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="slot" Property="ShaderEnabled" Value="True" />
<Setter TargetName="slot" Property="Intensity" Value="0.6" />
<Setter TargetName="emboss" Property="ShaderEnabled" Value="False" />
<Setter TargetName="slot" Property="Foreground" Value="{DynamicResource PrimaryPressedBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="emboss" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
<!--<Setter TargetName="emboss" Property="ShaderEnabled" Value="False" />-->
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 拟态按钮,按下后显示深度效果 --> <!-- 拟态按钮,按下后显示深度效果 -->
<Style x:Key="NeuButtonStyle" TargetType="{x:Type Button}"> <Style x:Key="NeuButtonStyle" TargetType="{x:Type Button}">
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" /> <Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" /> <Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" /> <Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="BorderThickness" Value="0" /> <Setter Property="BorderThickness" Value="0" />
<Setter Property="Padding" Value="10,4" /> <Setter Property="Padding" Value="10,4" />
<Setter Property="FontSize" Value="14" /> <Setter Property="FontSize" Value="14" />
@@ -89,13 +164,16 @@
<decorations:EmbossBorder <decorations:EmbossBorder
x:Name="emboss" x:Name="emboss"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
Intensity="0.5" Intensity="0.8"
ShaderEnabled="True" /> ShaderEnabled="True" />
<decorations:SlotBorder <decorations:SlotBorder
x:Name="slot" x:Name="slot"
Margin="0" Margin="0"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Intensity="0" Intensity="0"
ShaderEnabled="False"> ShaderEnabled="False">
<ContentPresenter <ContentPresenter
@@ -115,14 +193,13 @@
<!--<Setter Property="BorderThickness" Value="1" />--> <!--<Setter Property="BorderThickness" Value="1" />-->
</Trigger> </Trigger>
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="slot" Property="Intensity" Value="0" /> <Setter TargetName="emboss" Property="Intensity" Value="0.4" />
<Setter TargetName="emboss" Property="Intensity" Value="0" />
<Setter TargetName="slot" Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" /> <Setter TargetName="slot" Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
</Trigger> </Trigger>
<Trigger Property="IsPressed" Value="True"> <Trigger Property="IsPressed" Value="True">
<Setter TargetName="slot" Property="ShaderEnabled" Value="True" /> <Setter TargetName="slot" Property="ShaderEnabled" Value="True" />
<Setter TargetName="slot" Property="Intensity" Value="0.6" /> <Setter TargetName="slot" Property="Intensity" Value="0.6" />
<Setter TargetName="emboss" Property="Intensity" Value="0" /> <Setter TargetName="emboss" Property="ShaderEnabled" Value="False" />
<Setter TargetName="slot" Property="Foreground" Value="{DynamicResource PrimaryPressedBrush}" /> <Setter TargetName="slot" Property="Foreground" Value="{DynamicResource PrimaryPressedBrush}" />
</Trigger> </Trigger>
<Trigger Property="IsEnabled" Value="False"> <Trigger Property="IsEnabled" Value="False">
@@ -130,7 +207,6 @@
<Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" /> <Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
<!--<Setter TargetName="emboss" Property="ShaderEnabled" Value="False" />--> <!--<Setter TargetName="emboss" Property="ShaderEnabled" Value="False" />-->
</Trigger> </Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
@@ -206,10 +282,6 @@
</decorations:EmbossBorder> </decorations:EmbossBorder>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<!--<Trigger Property="IsDefaulted" Value="True">
<Setter Property="BorderBrush" TargetName="border"
Value="{StaticResource PrimaryBrush}" />
</Trigger>-->
<!-- 前缀图标可见性 --> <!-- 前缀图标可见性 -->
<Trigger Property="assists:ButtonAssist.Icon" Value="{x:Null}"> <Trigger Property="assists:ButtonAssist.Icon" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" /> <Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />

View File

@@ -18,7 +18,6 @@
<Setter Property="Intensity" Value="1" /> <Setter Property="Intensity" Value="1" />
<Setter Property="LightShadowBrush" Value="{DynamicResource LightShadowBrush}" /> <Setter Property="LightShadowBrush" Value="{DynamicResource LightShadowBrush}" />
<Setter Property="DarkShadowBrush" Value="{DynamicResource DarkShadowBrush}" /> <Setter Property="DarkShadowBrush" Value="{DynamicResource DarkShadowBrush}" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type decorations:EmbossBorder}"> <ControlTemplate TargetType="{x:Type decorations:EmbossBorder}">

View File

@@ -1,14 +1,14 @@
<ResourceDictionary <ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:decorations="clr-namespace:NeoUI.Controls.Decorations" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:decorations="clr-namespace:NeoUI.Controls.Decorations">
<Style TargetType="{x:Type decorations:LightedSurface}"> <Style TargetType="{x:Type decorations:LightedSurface}">
<Setter Property="Focusable" Value="False" /> <Setter Property="Focusable" Value="False" />
<Setter Property="LightColorBrush" Value="#FF111319" /> <Setter Property="LightColorBrush" Value="#FF111319" />
<Setter Property="LightSize" Value="200" /> <Setter Property="LightSize" Value="200" />
<Setter Property="Padding" Value="5" /> <Setter Property="Padding" Value="5" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" /> <Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" /> <Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="HorizontalContentAlignment" Value="Center" />
@@ -19,32 +19,32 @@
<ControlTemplate.Resources> <ControlTemplate.Resources>
<Storyboard x:Key="ShowLight"> <Storyboard x:Key="ShowLight">
<DoubleAnimation <DoubleAnimation
Duration="0:0:0.2"
Storyboard.TargetProperty="LightIntensity" Storyboard.TargetProperty="LightIntensity"
To="1" /> To="1"
Duration="0:0:0.2" />
</Storyboard> </Storyboard>
<Storyboard x:Key="HideLight"> <Storyboard x:Key="HideLight">
<DoubleAnimation <DoubleAnimation
Duration="0:0:0.2"
Storyboard.TargetProperty="LightIntensity" Storyboard.TargetProperty="LightIntensity"
To="0" /> To="0"
Duration="0:0:0.2" />
</Storyboard> </Storyboard>
</ControlTemplate.Resources> </ControlTemplate.Resources>
<Border <Border
x:Name="PART_lightBorder"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
CornerRadius="{TemplateBinding CornerRadius}" BorderBrush="{TemplateBinding BorderBrush}"
x:Name="PART_lightBorder"> BorderThickness="{TemplateBinding BorderThickness}"
<Border BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="{TemplateBinding CornerRadius}"> CornerRadius="{TemplateBinding CornerRadius}">
<ContentPresenter <ContentPresenter
Focusable="False" x:Name="contentPresenter"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}"
Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
RecognizesAccessKey="True" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Focusable="False"
TextElement.Foreground="{TemplateBinding Foreground}" RecognizesAccessKey="True"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
x:Name="contentPresenter" /> TextElement.Foreground="{TemplateBinding Foreground}" />
</Border>
</Border> </Border>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">

View File

@@ -3,9 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:assists="clr-namespace:NeoUI.Assists" xmlns:assists="clr-namespace:NeoUI.Assists"
xmlns:converters="clr-namespace:NeoUI.Converters" xmlns:converters="clr-namespace:NeoUI.Converters"
xmlns:internal="clr-namespace:NeoUI.Converters.Internal" xmlns:decorations="clr-namespace:NeoUI.Controls.Decorations"
xmlns:decorations="clr-namespace:NeoUI.Controls.Decorations"> xmlns:internal="clr-namespace:NeoUI.Converters.Internal">
<!-- 不支持垂直方向 -->
<Style x:Key="SlideTabGroupListBoxStyle" TargetType="ListBox"> <Style x:Key="SlideTabGroupListBoxStyle" TargetType="ListBox">
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" /> <Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="BorderThickness" Value="1" /> <Setter Property="BorderThickness" Value="1" />
@@ -28,6 +28,14 @@
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}"> <ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid Background="Transparent"> <Grid Background="Transparent">
<!-- 选中指示器 -->
<decorations:SlotBorder
x:Name="slot"
Padding="-4"
CornerRadius="{Binding Path=(assists:ControlAssist.CornerRadius), RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}"
Intensity="0.2"
Visibility="Collapsed"
ShaderEnabled="False"/>
<ContentPresenter <ContentPresenter
Margin="{TemplateBinding Padding}" Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
@@ -38,8 +46,18 @@
<Trigger Property="IsSelected" Value="True"> <Trigger Property="IsSelected" Value="True">
<!-- 被选中时,仅改变文字颜色 --> <!-- 被选中时,仅改变文字颜色 -->
<Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" /> <Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
<!-- 主题高亮颜色 --> <Setter TargetName="slot" Property="ShaderEnabled" Value="True" />
</Trigger> </Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
</Trigger>
<!--多选时,隐藏指示器-->
<DataTrigger Binding="{Binding Path=SelectionMode, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}" Value="Multiple">
<Setter TargetName="slot" Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=SelectionMode, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}" Value="Extend">
<Setter TargetName="slot" Property="Visibility" Value="Visible" />
</DataTrigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
@@ -63,7 +81,7 @@
CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}" CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}"
Intensity="0.8" /> Intensity="0.8" />
<!-- Canvas 用于精确定位滑块 --> <!-- Canvas 用于精确定位滑块 -->
<Canvas> <Canvas x:Name="PART_SlideCanvas">
<!-- 滑块元素Name 是关键,行为代码通过它来查找并控制动画 --> <!-- 滑块元素Name 是关键,行为代码通过它来查找并控制动画 -->
<decorations:SlotBorder <decorations:SlotBorder
x:Name="PART_SelectionIndicator" x:Name="PART_SelectionIndicator"
@@ -76,10 +94,21 @@
</decorations:SlotBorder.RenderTransform> </decorations:SlotBorder.RenderTransform>
</decorations:SlotBorder> </decorations:SlotBorder>
</Canvas> </Canvas>
<!-- ItemsPresenter 必须在滑块上层,以显示所有 Tab 项 --> <!-- ItemsPresenter 必须在滑块上层,以显示所有 Tab 项 -->
<ItemsPresenter /> <ItemsPresenter />
</Grid> </Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
</Trigger>
<!--隐藏滑块-->
<Trigger Property="SelectionMode" Value="Multiple">
<Setter TargetName="PART_SlideCanvas" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="SelectionMode" Value="Extended">
<Setter TargetName="PART_SlideCanvas" Property="Visibility" Value="Collapsed" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
</Setter> </Setter>
@@ -89,9 +118,7 @@
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" /> <Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="BorderThickness" Value="0" /> <Setter Property="BorderThickness" Value="0" />
<Setter Property="assists:SelectorAssist.Orientation" Value="Horizontal" /> <Setter Property="assists:SelectorAssist.Orientation" Value="Horizontal" />
<Setter Property="assists:ControlAssist.CornerRadius" Value="10" /> <Setter Property="assists:ControlAssist.CornerRadius" Value="10" />
<!-- 关键将上面定义的Item样式应用到ListBox的每个项目上 -->
<Setter Property="ItemContainerStyle"> <Setter Property="ItemContainerStyle">
<Setter.Value> <Setter.Value>
<Style TargetType="{x:Type ListBoxItem}"> <Style TargetType="{x:Type ListBoxItem}">
@@ -121,10 +148,6 @@
<Setter TargetName="emboss" Property="ShaderEnabled" Value="True" /> <Setter TargetName="emboss" Property="ShaderEnabled" Value="True" />
<Setter TargetName="emboss" Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" /> <Setter TargetName="emboss" Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" /> <Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
<Trigger.EnterActions> <Trigger.EnterActions>
<BeginStoryboard> <BeginStoryboard>
<Storyboard> <Storyboard>
@@ -148,6 +171,9 @@
</BeginStoryboard> </BeginStoryboard>
</Trigger.ExitActions> </Trigger.ExitActions>
</Trigger> </Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}"/>
</Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>

View File

@@ -12,7 +12,6 @@
<Setter Property="assists:ShadingAssist.DisabledForeground" Value="{DynamicResource TextDisabledBrush}" /> <Setter Property="assists:ShadingAssist.DisabledForeground" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="Background" Value="Transparent" /> <Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" /> <Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<!--<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True"/>-->
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" /> <Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="FontSize" Value="14" /> <Setter Property="FontSize" Value="14" />
<!--<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True"/>--> <!--<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True"/>-->
@@ -42,7 +41,7 @@
<MultiTrigger> <MultiTrigger>
<MultiTrigger.Conditions> <MultiTrigger.Conditions>
<!--<Condition Property="IsMouseOver" Value="True" />--> <!--<Condition Property="IsMouseOver" Value="True" />-->
<Condition Property="assists:WindowAssist.VisualState" Value="MouseOver" /> <Condition Property="assists:WindowAssist.WindowButtonState" Value="MouseOver" />
<Condition Property="Background" Value="Transparent" /> <Condition Property="Background" Value="Transparent" />
</MultiTrigger.Conditions> </MultiTrigger.Conditions>
<Setter TargetName="border" Property="Background" Value="{DynamicResource BackgroundLayoutBrush}" /> <Setter TargetName="border" Property="Background" Value="{DynamicResource BackgroundLayoutBrush}" />
@@ -54,7 +53,7 @@
<Setter Property="Opacity" Value="1" /> <Setter Property="Opacity" Value="1" />
</MultiTrigger> </MultiTrigger>
<!--<Trigger Property="IsPressed" Value="True">--> <!--<Trigger Property="IsPressed" Value="True">-->
<Trigger Property="assists:WindowAssist.VisualState" Value="Pressed"> <Trigger Property="assists:WindowAssist.WindowButtonState" Value="Pressed">
<Setter TargetName="border" Property="Effect"> <Setter TargetName="border" Property="Effect">
<Setter.Value> <Setter.Value>
<effects:BrightnessContrastEffect Brightness="0.05" /> <effects:BrightnessContrastEffect Brightness="0.05" />
@@ -319,7 +318,7 @@
<Style BasedOn="{StaticResource WindowButton}" TargetType="Button"> <Style BasedOn="{StaticResource WindowButton}" TargetType="Button">
<Style.Triggers> <Style.Triggers>
<!--<Trigger Property="IsMouseOver" Value="True">--> <!--<Trigger Property="IsMouseOver" Value="True">-->
<Trigger Property="assists:WindowAssist.VisualState" Value="MouseOver"> <Trigger Property="assists:WindowAssist.WindowButtonState" Value="MouseOver">
<Setter Property="Background" Value="{DynamicResource ErrorBrush}" /> <Setter Property="Background" Value="{DynamicResource ErrorBrush}" />
<Setter Property="Foreground" Value="#e0e0e0" /> <Setter Property="Foreground" Value="#e0e0e0" />
</Trigger> </Trigger>

View File

@@ -79,7 +79,7 @@ public class NeoWindow : Window
{ {
pressedButton = hoveredButton; pressedButton = hoveredButton;
// 3. 设置状态为 Pressed // 3. 设置状态为 Pressed
WindowAssist.SetVisualState(pressedButton, WindowButtonState.Pressed); WindowAssist.SetWindowButtonState(pressedButton, WindowButtonState.Pressed);
handled = true; handled = true;
} }
break; break;
@@ -116,7 +116,7 @@ public class NeoWindow : Window
// 离开旧按钮:如果之前有悬停的按钮,并且它当前不是"按下"状态,则恢复为"Normal" // 离开旧按钮:如果之前有悬停的按钮,并且它当前不是"按下"状态,则恢复为"Normal"
if (hoveredButton != null && hoveredButton != pressedButton) if (hoveredButton != null && hoveredButton != pressedButton)
{ {
WindowAssist.SetVisualState(hoveredButton, WindowButtonState.Normal); WindowAssist.SetWindowButtonState(hoveredButton, WindowButtonState.Normal);
} }
hoveredButton = currentHoveredButton; hoveredButton = currentHoveredButton;
@@ -124,7 +124,7 @@ public class NeoWindow : Window
// 进入新按钮:如果现在有一个新的悬停按钮,并且它当前不是"按下"状态,则切换为"MouseOver" // 进入新按钮:如果现在有一个新的悬停按钮,并且它当前不是"按下"状态,则切换为"MouseOver"
if (hoveredButton != null && hoveredButton != pressedButton) if (hoveredButton != null && hoveredButton != pressedButton)
{ {
WindowAssist.SetVisualState(hoveredButton, WindowButtonState.MouseOver); WindowAssist.SetWindowButtonState(hoveredButton, WindowButtonState.MouseOver);
} }
} }
} }
@@ -148,7 +148,7 @@ public class NeoWindow : Window
{ {
if (pressedButton != null) if (pressedButton != null)
{ {
WindowAssist.SetVisualState(pressedButton, WindowButtonState.Normal); WindowAssist.SetWindowButtonState(pressedButton, WindowButtonState.Normal);
pressedButton = null; pressedButton = null;
} }
UpdateHoverState(null); UpdateHoverState(null);

View File

@@ -397,7 +397,7 @@
Content="禁用按钮" Content="禁用按钮"
IsEnabled="False" /> IsEnabled="False" />
<Button Content="拟态" Style="{StaticResource NeuButtonStyle}" /> <Button Content="拟态" Style="{StaticResource NeuButtonStyle}"/>
<Button <Button
Content="禁用拟态" Content="禁用拟态"
IsEnabled="False" IsEnabled="False"
@@ -468,6 +468,10 @@
<RepeatButton Content="RepeatButton" /> <RepeatButton Content="RepeatButton" />
<RepeatButton Content="RepeatButton" IsEnabled="False" /> <RepeatButton Content="RepeatButton" IsEnabled="False" />
</UniformGrid> </UniformGrid>
<UniformGrid Rows="1">
<Button Style="{StaticResource IconButton}" n:ButtonAssist.Icon="{n:Icon SymbolValue=Add}"/>
<Button IsEnabled="False" Style="{StaticResource IconButton}" n:ButtonAssist.Icon="{n:Icon SymbolValue=Add}"/>
</UniformGrid>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
@@ -988,8 +992,7 @@
<TreeViewItem Header="A123" IsExpanded="True"> <TreeViewItem Header="A123" IsExpanded="True">
<TreeViewItem <TreeViewItem
Header="B123" Header="B123"
IsExpanded="True" IsExpanded="True">
IsSelected="True">
<TreeViewItem Header="C123" /> <TreeViewItem Header="C123" />
</TreeViewItem> </TreeViewItem>
<TreeViewItem Header="B456" IsEnabled="False" /> <TreeViewItem Header="B456" IsEnabled="False" />
@@ -1043,7 +1046,7 @@
</ListView> </ListView>
</n:FlexibleRowPanel> </n:FlexibleRowPanel>
<n:FlexibleRowPanel LayoutMode="Auto" Spacing="100"> <n:FlexibleRowPanel LayoutMode="Auto" Spacing="20">
<UniformGrid Columns="1"> <UniformGrid Columns="1">
<ListBox <ListBox
HorizontalAlignment="Center" HorizontalAlignment="Center"
@@ -1066,8 +1069,33 @@
<sys:String>Tab 3</sys:String> <sys:String>Tab 3</sys:String>
<sys:String>Another Tab</sys:String> <sys:String>Another Tab</sys:String>
</ListBox> </ListBox>
<ListBox
IsEnabled="False"
HorizontalAlignment="Center"
VerticalAlignment="Center"
n:ListBoxSlideBehavior.EnableSlideAnimation="True"
SelectedIndex="1"
Style="{StaticResource SlideTabGroupListBoxStyle}">
<!-- 这里是你的数据项 -->
<sys:String>Tab 1</sys:String>
<sys:String>Tab 2</sys:String>
<sys:String>Tab 3</sys:String>
<sys:String>Another Tab</sys:String>
</ListBox>
</UniformGrid> </UniformGrid>
<ListBox <ListBox
HorizontalAlignment="Center"
VerticalAlignment="Center"
n:SelectorAssist.Orientation="Vertical"
SelectedIndex="1"
SelectionMode="Multiple"
Style="{StaticResource TabGroupListBoxStyle}">
<ListBoxItem Content="Home" />
<ListBoxItem Content="Away" />
<ListBoxItem Content="Night" />
</ListBox>
<ListBox
IsEnabled="False"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
n:SelectorAssist.Orientation="Vertical" n:SelectorAssist.Orientation="Vertical"
@@ -1078,6 +1106,7 @@
<ListBoxItem Content="Night" /> <ListBoxItem Content="Night" />
</ListBox> </ListBox>
<ListBox <ListBox
SelectionMode="Multiple"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
n:ListBoxSlideBehavior.EnableSlideAnimation="True" n:ListBoxSlideBehavior.EnableSlideAnimation="True"
@@ -1190,15 +1219,15 @@
ToolTip="双击展开详情"> ToolTip="双击展开详情">
<i:Interaction.Triggers> <i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick"> <i:EventTrigger EventName="MouseDoubleClick">
<i:InvokeCommandAction Command="{Binding ToggleDetailsCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}, Path=SelectedItem}" /> <i:InvokeCommandAction Command="{Binding ToggleDetailsCommand}" CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
</i:EventTrigger> </i:EventTrigger>
</i:Interaction.Triggers> </i:Interaction.Triggers>
<!-- 2. RowStyle现在只负责绑定详情可见性不再处理事件 --> <!-- 2. RowStyle现在只负责绑定详情可见性不再处理事件 -->
<DataGrid.RowStyle> <n:NeuDataGrid.RowStyle>
<Style BasedOn="{StaticResource DataGridRowDefault}" TargetType="DataGridRow"> <Style BasedOn="{StaticResource DataGridRowDefault}" TargetType="{x:Type DataGridRow}">
<Setter Property="DetailsVisibility" Value="{Binding IsDetailsVisible, Converter={x:Static n:BooleanToVisibilityConverter.CollapsedInstance}, Mode=TwoWay}" /> <Setter Property="DetailsVisibility" Value="{Binding IsDetailsVisible, Converter={x:Static n:BooleanToVisibilityConverter.CollapsedInstance}, Mode=TwoWay}" />
</Style> </Style>
</DataGrid.RowStyle> </n:NeuDataGrid.RowStyle>
<n:NeuDataGrid.RowDetailsTemplate> <n:NeuDataGrid.RowDetailsTemplate>
<DataTemplate> <DataTemplate>
<StackPanel Margin="10"> <StackPanel Margin="10">
@@ -1228,7 +1257,7 @@
<HierarchicalDataTemplate DataType="{x:Type neuwpftest:TreeNodeItem}" ItemsSource="{Binding Children}"> <HierarchicalDataTemplate DataType="{x:Type neuwpftest:TreeNodeItem}" ItemsSource="{Binding Children}">
<!-- 使用 GridViewRowPresenter 来确保内容与表头列对齐 --> <!-- 使用 GridViewRowPresenter 来确保内容与表头列对齐 -->
<!-- Columns 属性必须绑定到 TreeGrid 的 Columns 集合 --> <!-- Columns 属性必须绑定到 TreeGrid 的 Columns 集合 -->
<GridViewRowPresenter Columns="{Binding Path=Columns, RelativeSource={RelativeSource AncestorType=n:TreeGrid}}" Content="{Binding}" /> <GridViewRowPresenter Columns="{Binding Columns, RelativeSource={RelativeSource AncestorType={x:Type n:TreeGrid}}}" Content="{Binding}" />
</HierarchicalDataTemplate> </HierarchicalDataTemplate>
</n:TreeGrid.ItemTemplate> </n:TreeGrid.ItemTemplate>
<!-- 直接定义 GridViewColumn 集合,就像使用 ListView 一样 --> <!-- 直接定义 GridViewColumn 集合,就像使用 ListView 一样 -->
@@ -1261,7 +1290,7 @@
Width="200" Width="200"
BorderBrush="Gray" BorderBrush="Gray"
BorderThickness="1"> BorderThickness="1">
<n:AccordionItem Header="User Profile"> <n:AccordionItem Header="User Profile" IsExpanded="True">
<StackPanel Margin="10"> <StackPanel Margin="10">
<TextBlock Text="Name: John Doe" /> <TextBlock Text="Name: John Doe" />
<TextBlock Text="Email: john.doe@example.com" /> <TextBlock Text="Email: john.doe@example.com" />
@@ -1279,13 +1308,13 @@
<TextBlock Text="Email: john.doe@example.com" /> <TextBlock Text="Email: john.doe@example.com" />
</StackPanel> </StackPanel>
</n:AccordionItem> </n:AccordionItem>
<n:AccordionItem Header="Application Settings"> <n:AccordionItem Header="Application Settings" IsExpanded="True">
<StackPanel Margin="10"> <StackPanel>
<CheckBox Content="Enable Dark Mode" /> <CheckBox Content="Enable Dark Mode" />
<CheckBox Content="Auto-save every 5 minutes" /> <CheckBox Content="Auto-save every 5 minutes" />
</StackPanel> </StackPanel>
</n:AccordionItem> </n:AccordionItem>
<n:AccordionItem Header="Help &amp; Support"> <n:AccordionItem Header="Help &amp; Support" IsExpanded="True">
<TextBlock <TextBlock
Margin="10" Margin="10"
Text="For support, please visit our website." Text="For support, please visit our website."
@@ -1297,7 +1326,7 @@
BorderThickness="1" BorderThickness="1"
ItemsSource="{Binding Items}"> ItemsSource="{Binding Items}">
<n:Accordion.ItemContainerStyle> <n:Accordion.ItemContainerStyle>
<Style BasedOn="{StaticResource {x:Type n:AccordionItem}}" TargetType="n:AccordionItem"> <Style BasedOn="{StaticResource {x:Type n:AccordionItem}}" TargetType="{x:Type n:AccordionItem}">
<Setter Property="Header" Value="{Binding Label}" /> <Setter Property="Header" Value="{Binding Label}" />
<Setter Property="Content"> <Setter Property="Content">
<Setter.Value> <Setter.Value>