更新命名空间,优化部分交互

This commit is contained in:
GG Z
2025-09-06 00:36:23 +08:00
parent f03dd8ac58
commit 61ff71c5be
33 changed files with 495 additions and 232 deletions

View File

@@ -0,0 +1,140 @@
// NeoUI/Assists/PopupAssist.cs
using System;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
namespace NeoUI.Assists
{
/// <summary>
/// 提供附加属性,为 StaysOpen="True" 的 Popup 附加原生 ComboBox 的标准行为。
/// 当 SimulateNativeBehavior="True" 时:
/// 1. 点击外部、拖动窗口或窗口失活时Popup 会自动关闭。
/// 2. Popup 打开时,会阻止外部内容的鼠标滚轮滚动。
/// </summary>
public static class PopupAssist
{
#region SimulateNativeBehavior Attached Property
public static readonly DependencyProperty SimulateNativeBehaviorProperty =
DependencyProperty.RegisterAttached(
"SimulateNativeBehavior", // 【命名已更新】
typeof(bool),
typeof(PopupAssist),
new PropertyMetadata(false, OnSimulateNativeBehaviorChanged)); // 【回调已更新】
public static void SetSimulateNativeBehavior(DependencyObject element, bool value)
{
element.SetValue(SimulateNativeBehaviorProperty, value);
}
public static bool GetSimulateNativeBehavior(DependencyObject element)
{
return (bool)element.GetValue(SimulateNativeBehaviorProperty);
}
#endregion
#region Private State Management Properties
private static readonly DependencyProperty PreviewMouseDownHandlerProperty =
DependencyProperty.RegisterAttached("PreviewMouseDownHandler", typeof(MouseButtonEventHandler), typeof(PopupAssist));
private static readonly DependencyProperty WindowEventHandlerProperty =
DependencyProperty.RegisterAttached("WindowEventHandler", typeof(EventHandler), typeof(PopupAssist));
private static readonly DependencyProperty PreviewMouseWheelHandlerProperty =
DependencyProperty.RegisterAttached("PreviewMouseWheelHandler", typeof(MouseWheelEventHandler), typeof(PopupAssist));
#endregion
// 【回调已更新】
private static void OnSimulateNativeBehaviorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (!(d is Popup popup)) return;
if ((bool)e.NewValue)
{
popup.Opened += OnPopupOpened;
}
else
{
popup.Opened -= OnPopupOpened;
}
}
private static void OnPopupOpened(object sender, EventArgs e)
{
var popup = sender as Popup;
if (popup == null) return;
var window = Window.GetWindow(popup);
if (window == null) return;
// --- 自动关闭逻辑 ---
EventHandler windowEventHandler = (s, args) =>
{
popup.Dispatcher.BeginInvoke(new Action(() => {
popup.IsOpen = false;
}));
};
popup.SetValue(WindowEventHandlerProperty, windowEventHandler);
window.Deactivated += windowEventHandler;
window.LocationChanged += windowEventHandler;
MouseButtonEventHandler mouseDownHandler = (s, args) =>
{
if (popup.IsMouseOver || (popup.PlacementTarget != null && popup.PlacementTarget.IsMouseOver))
{
return;
}
popup.IsOpen = false;
};
popup.SetValue(PreviewMouseDownHandlerProperty, mouseDownHandler);
window.AddHandler(UIElement.PreviewMouseDownEvent, mouseDownHandler, true);
// --- 鼠标滚轮拦截逻辑 ---
MouseWheelEventHandler mouseWheelHandler = (s, args) =>
{
if (!popup.IsMouseOver)
{
args.Handled = true;
}
};
popup.SetValue(PreviewMouseWheelHandlerProperty, mouseWheelHandler);
window.AddHandler(UIElement.PreviewMouseWheelEvent, mouseWheelHandler, true);
popup.Closed += OnPopupClosed;
}
private static void OnPopupClosed(object sender, EventArgs e)
{
var popup = sender as Popup;
if (popup == null) return;
popup.Closed -= OnPopupClosed;
var window = Window.GetWindow(popup);
if (window == null) return;
if (popup.GetValue(WindowEventHandlerProperty) is EventHandler windowEventHandler)
{
window.Deactivated -= windowEventHandler;
window.LocationChanged -= windowEventHandler;
popup.ClearValue(WindowEventHandlerProperty);
}
if (popup.GetValue(PreviewMouseDownHandlerProperty) is MouseButtonEventHandler mouseDownHandler)
{
window.RemoveHandler(UIElement.PreviewMouseDownEvent, mouseDownHandler);
popup.ClearValue(PreviewMouseDownHandlerProperty);
}
if (popup.GetValue(PreviewMouseWheelHandlerProperty) is MouseWheelEventHandler mouseWheelHandler)
{
window.RemoveHandler(UIElement.PreviewMouseWheelEvent, mouseWheelHandler);
popup.ClearValue(PreviewMouseWheelHandlerProperty);
}
}
}
}

View File

@@ -1,16 +1,16 @@
<ResourceDictionary <ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:NeoUI.Controls" xmlns:controls="clr-namespace:NeoUI.Controls"
xmlns:decorations="clr-namespace:NeoUI.Controls.Decorations"> xmlns:decorations="clr-namespace:NeoUI.Controls.Decorations">
<Style TargetType="{x:Type local:AccordionItem}"> <Style TargetType="{x:Type controls:AccordionItem}">
<Setter Property="VerticalAlignment" Value="Top" /> <Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" /> <Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type local:AccordionItem}"> <ControlTemplate TargetType="{x:Type controls:AccordionItem}">
<Border <Border
Padding="{TemplateBinding Padding}" Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
@@ -136,7 +136,7 @@
</Style> </Style>
<!-- Accordion Style (无改动) --> <!-- Accordion Style (无改动) -->
<Style TargetType="{x:Type local:Accordion}"> <Style TargetType="{x:Type controls:Accordion}">
<Setter Property="ItemsPanel"> <Setter Property="ItemsPanel">
<Setter.Value> <Setter.Value>
<ItemsPanelTemplate> <ItemsPanelTemplate>
@@ -146,7 +146,7 @@
</Setter> </Setter>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type local:Accordion}"> <ControlTemplate TargetType="{x:Type controls:Accordion}">
<decorations:EmbossBorder <decorations:EmbossBorder
Background="{DynamicResource ControlBackgroundNormalBrush}" Background="{DynamicResource ControlBackgroundNormalBrush}"
BorderBrush="{DynamicResource BorderNormalBrush}" BorderBrush="{DynamicResource BorderNormalBrush}"

View File

@@ -0,0 +1,94 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
namespace NeoUI.Controls
{
/// <summary>
/// 一个使用AdornerLayer实现、可作为原生Popup直接替代品的控件。
/// 它能被窗口和ScrollViewer正确裁剪。
/// </summary>
public class AdornerPopup : ContentControl
{
private Adorner? _adorner;
// 【修正】将 _childCache 的类型从 UIElement? 更改为 FrameworkElement?
private FrameworkElement? _childCache;
#region Dependency Properties (仿Popup)
public static readonly DependencyProperty IsOpenProperty =
DependencyProperty.Register("IsOpen", typeof(bool), typeof(AdornerPopup),
new PropertyMetadata(false, OnIsOpenChanged));
public bool IsOpen
{
get => (bool)GetValue(IsOpenProperty);
set => SetValue(IsOpenProperty, value);
}
public static readonly DependencyProperty PlacementTargetProperty =
DependencyProperty.Register("PlacementTarget", typeof(UIElement), typeof(AdornerPopup),
new PropertyMetadata(null));
public UIElement PlacementTarget
{
get => (UIElement)GetValue(PlacementTargetProperty);
set => SetValue(PlacementTargetProperty, value);
}
#endregion
private static void OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is AdornerPopup popup)
{
popup.UpdateAdorner();
}
}
private void UpdateAdorner()
{
var target = PlacementTarget ?? this;
var adornerLayer = AdornerLayer.GetAdornerLayer(target);
if (adornerLayer == null) return;
if (IsOpen)
{
if (_adorner != null) return;
// 【修正】将 Content 转换为 FrameworkElement
_childCache = Content as FrameworkElement;
if (_childCache == null) return;
Content = null;
// 关键将自身的DataContext传递给弹出的内容以修复MVVM绑定
// 因为 _childCache 现在是 FrameworkElement 类型,所以可以访问 DataContext
_childCache.DataContext = DataContext;
_adorner = new ContentAdorner(target, _childCache);
adornerLayer.Add(_adorner);
}
else
{
if (_adorner == null) return;
adornerLayer.Remove(_adorner);
if (_childCache != null)
{
// 清理 DataContext
_childCache.DataContext = null;
// 恢复内容
Content = _childCache;
_childCache = null;
}
_adorner = null;
}
}
}
}

View File

@@ -2,15 +2,18 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:local="clr-namespace:NeoUI.Controls" xmlns:controls="clr-namespace:NeoUI.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!--<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="FlattenTextBox.xaml" />
</ResourceDictionary.MergedDictionaries>-->
<Style TargetType="{x:Type local:AutoComplete}"> <Style TargetType="{x:Type controls:AutoComplete}">
<Setter Property="assists:InputAssist.Placeholder" Value="请输入..." /> <Setter Property="assists:InputAssist.Placeholder" Value="请输入..." />
<Setter Property="assists:InputAssist.Clearable" Value="True" /> <Setter Property="assists:InputAssist.Clearable" Value="True" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type local:AutoComplete}"> <ControlTemplate TargetType="{x:Type controls:AutoComplete}">
<Grid> <Grid>
<TextBox <TextBox
Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
@@ -24,7 +27,8 @@
MinWidth="{Binding ActualWidth, ElementName=PART_TextBox}" MinWidth="{Binding ActualWidth, ElementName=PART_TextBox}"
PlacementTarget="{Binding ElementName=PART_TextBox}" PlacementTarget="{Binding ElementName=PART_TextBox}"
PopupAnimation="Slide" PopupAnimation="Slide"
StaysOpen="False" assists:PopupAssist.SimulateNativeBehavior="True"
StaysOpen="True"
x:Name="PART_Popup"> x:Name="PART_Popup">
<Border <Border
Background="{DynamicResource BackgroundFloatingBrush}" Background="{DynamicResource BackgroundFloatingBrush}"
@@ -80,7 +84,7 @@
<ContentPresenter.Content> <ContentPresenter.Content>
<MultiBinding Converter="{x:Static converters:StringMatchConverter.Instance}"> <MultiBinding Converter="{x:Static converters:StringMatchConverter.Instance}">
<Binding /> <Binding />
<Binding Path="Text" RelativeSource="{RelativeSource AncestorType=local:AutoComplete}" /> <Binding Path="Text" RelativeSource="{RelativeSource AncestorType=controls:AutoComplete}" />
</MultiBinding> </MultiBinding>
</ContentPresenter.Content> </ContentPresenter.Content>
</ContentPresenter> </ContentPresenter>

View File

@@ -4,7 +4,7 @@
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:internal="clr-namespace:NeoUI.Converters.Internal"
xmlns:local="clr-namespace:NeoUI.Controls" xmlns:controls="clr-namespace:NeoUI.Controls"
xmlns:decorations="clr-namespace:NeoUI.Controls.Decorations"> xmlns:decorations="clr-namespace:NeoUI.Controls.Decorations">
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
@@ -46,46 +46,7 @@
To="0.4" To="0.4"
Duration="0" /> Duration="0" />
</Storyboard> </Storyboard>
<!--<Style x:Key="DefaultCascaderListBoxItemStyle" TargetType="ListBoxItem">
<Setter Property="Padding" Value="4,2" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border
x:Name="Bd"
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
SnapsToDevicePixels="true">
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource ControlBackgroundSelectedBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextInverseBrush}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource ControlBackgroundHoverBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>-->
<Style x:Key="DefaultCascaderPanelStyle" TargetType="ListBox"> <Style x:Key="DefaultCascaderPanelStyle" TargetType="ListBox">
<!--<Setter Property="ItemContainerStyle" Value="{DynamicResource DefaultCascaderListBoxItemStyle}" />--> <!--<Setter Property="ItemContainerStyle" Value="{DynamicResource DefaultCascaderListBoxItemStyle}" />-->
<Setter Property="Background" Value="{DynamicResource BackgroundFloatingBrush}" /> <Setter Property="Background" Value="{DynamicResource BackgroundFloatingBrush}" />
@@ -119,7 +80,7 @@
<!-- 第一个绑定:当前的数据项 --> <!-- 第一个绑定:当前的数据项 -->
<Binding Path="." /> <Binding Path="." />
<!-- 第二个绑定:从祖先 Cascader 获取 DisplayMemberPath --> <!-- 第二个绑定:从祖先 Cascader 获取 DisplayMemberPath -->
<Binding Path="DisplayMemberPath" RelativeSource="{RelativeSource AncestorType=local:Cascader}" /> <Binding Path="DisplayMemberPath" RelativeSource="{RelativeSource AncestorType=controls:Cascader}" />
</MultiBinding> </MultiBinding>
</TextBlock.Text> </TextBlock.Text>
</TextBlock> </TextBlock>
@@ -141,7 +102,7 @@
<DataTrigger.Binding> <DataTrigger.Binding>
<MultiBinding Converter="{x:Static internal:HasChildrenMultiConverter.Instance}"> <MultiBinding Converter="{x:Static internal:HasChildrenMultiConverter.Instance}">
<Binding Path="." /> <Binding Path="." />
<Binding Path="SubmenuMemberPath" RelativeSource="{RelativeSource AncestorType=local:Cascader}" /> <Binding Path="SubmenuMemberPath" RelativeSource="{RelativeSource AncestorType=controls:Cascader}" />
</MultiBinding> </MultiBinding>
</DataTrigger.Binding> </DataTrigger.Binding>
<Setter TargetName="Arrow" Property="Visibility" Value="Visible" /> <Setter TargetName="Arrow" Property="Visibility" Value="Visible" />
@@ -181,7 +142,7 @@
</Setter> </Setter>
</Style> </Style>
<Style TargetType="{x:Type local:Cascader}"> <Style TargetType="{x:Type controls:Cascader}">
<Setter Property="BorderThickness" Value="1" /> <Setter Property="BorderThickness" Value="1" />
<Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" /> <Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
@@ -200,7 +161,7 @@
<Setter Property="PanelStyle" Value="{StaticResource DefaultCascaderPanelStyle}" /> <Setter Property="PanelStyle" Value="{StaticResource DefaultCascaderPanelStyle}" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type local:Cascader}"> <ControlTemplate TargetType="{x:Type controls:Cascader}">
<!-- ... Grid 和 ToggleButton 保持不变 ... --> <!-- ... Grid 和 ToggleButton 保持不变 ... -->
<Grid x:Name="templateRoot" SnapsToDevicePixels="true"> <Grid x:Name="templateRoot" SnapsToDevicePixels="true">
<ToggleButton <ToggleButton
@@ -233,7 +194,7 @@
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False" IsHitTestVisible="False"
Text="{Binding SelectedText, RelativeSource={RelativeSource AncestorType=local:Cascader}}" Text="{Binding SelectedText, RelativeSource={RelativeSource AncestorType=controls:Cascader}}"
TextTrimming="CharacterEllipsis" /> TextTrimming="CharacterEllipsis" />
<Border <Border
x:Name="splitBorder" x:Name="splitBorder"
@@ -259,7 +220,7 @@
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False" IsHitTestVisible="False"
Text="{Binding SelectedText, RelativeSource={RelativeSource AncestorType=local:Cascader}}" Text="{Binding SelectedText, RelativeSource={RelativeSource AncestorType=controls:Cascader}}"
TextTrimming="CharacterEllipsis" /> TextTrimming="CharacterEllipsis" />
<Path <Path
x:Name="arrow" x:Name="arrow"
@@ -311,12 +272,12 @@
VerticalAlignment="Center" VerticalAlignment="Center"
Foreground="{DynamicResource TextPlaceholderBrush}" Foreground="{DynamicResource TextPlaceholderBrush}"
IsHitTestVisible="False" IsHitTestVisible="False"
Text="{Binding Path=(assists:SelectorAssist.Placeholder), RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:Cascader}}"> Text="{Binding Path=(assists:SelectorAssist.Placeholder), RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=controls:Cascader}}">
<TextBlock.Style> <TextBlock.Style>
<Style TargetType="TextBlock"> <Style TargetType="TextBlock">
<Setter Property="Visibility" Value="Collapsed" /> <Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding SelectedText, RelativeSource={RelativeSource AncestorType=local:Cascader}}" Value=""> <DataTrigger Binding="{Binding SelectedText, RelativeSource={RelativeSource AncestorType=controls:Cascader}}" Value="">
<Setter Property="Visibility" Value="Visible" /> <Setter Property="Visibility" Value="Visible" />
</DataTrigger> </DataTrigger>
</Style.Triggers> </Style.Triggers>
@@ -324,6 +285,7 @@
</TextBlock.Style> </TextBlock.Style>
</TextBlock> </TextBlock>
<Popup <Popup
assists:PopupAssist.SimulateNativeBehavior="True"
x:Name="PART_Popup" x:Name="PART_Popup"
Margin="-8" Margin="-8"
AllowsTransparency="True" AllowsTransparency="True"
@@ -331,12 +293,12 @@
Placement="Bottom" Placement="Bottom"
PlacementTarget="{Binding ElementName=PART_ToggleButton}" PlacementTarget="{Binding ElementName=PART_ToggleButton}"
PopupAnimation="Slide" PopupAnimation="Slide"
StaysOpen="False"> StaysOpen="True">
<Border <Border
MinWidth="{Binding ActualWidth, ElementName=templateRoot}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
MaxHeight="300" MaxHeight="300"
Margin="8" Margin="8"
Background="{DynamicResource BackgroundLayoutBrush}" Background="{DynamicResource BackgroundFloatingBrush}"
BorderBrush="{DynamicResource BorderNormalBrush}" BorderBrush="{DynamicResource BorderNormalBrush}"
BorderThickness="1" BorderThickness="1"
CornerRadius="4" CornerRadius="4"
@@ -383,7 +345,7 @@
<Button <Button
Padding="4,2" Padding="4,2"
HorizontalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
Command="{Binding RelativeSource={RelativeSource AncestorType=local:Cascader}, Path=SelectSearchResultCommand}" Command="{Binding RelativeSource={RelativeSource AncestorType=controls:Cascader}, Path=SelectSearchResultCommand}"
CommandParameter="{Binding}"> CommandParameter="{Binding}">
<Button.Template> <Button.Template>
<ControlTemplate TargetType="Button"> <ControlTemplate TargetType="Button">

View File

@@ -9,7 +9,7 @@ namespace NeoUI.Controls;
/// <summary> /// <summary>
/// 用于实现级联选择器功能的控件类。该控件允许用户从多层级的数据源中选择一个值,通常应用于需要按类别或层级进行选择的场景。 /// 用于实现级联选择器功能的控件类。该控件允许用户从多层级的数据源中选择一个值,通常应用于需要按类别或层级进行选择的场景。
/// </summary> /// </summary>
[TemplatePart(Name = "PART_Popup", Type = typeof(Popup))] //[TemplatePart(Name = "PART_Popup", Type = typeof(Popup))]
public class Cascader : Control public class Cascader : Control
{ {
private static readonly DependencyPropertyKey FilteredItemsSourcePropertyKey = DependencyProperty.RegisterReadOnly("FilteredItemsSource", typeof(IEnumerable), typeof(Cascader), new PropertyMetadata(null)); private static readonly DependencyPropertyKey FilteredItemsSourcePropertyKey = DependencyProperty.RegisterReadOnly("FilteredItemsSource", typeof(IEnumerable), typeof(Cascader), new PropertyMetadata(null));

View File

@@ -417,12 +417,13 @@
</ToggleButton> </ToggleButton>
<Popup <Popup
assists:PopupAssist.SimulateNativeBehavior="True"
AllowsTransparency="True" AllowsTransparency="True"
IsOpen="{Binding IsChecked, ElementName=PART_Trigger, Mode=TwoWay}" IsOpen="{Binding IsChecked, ElementName=PART_Trigger, Mode=TwoWay}"
Placement="Bottom" Placement="Bottom"
PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
PopupAnimation="None" PopupAnimation="None"
StaysOpen="False" StaysOpen="True"
x:Name="PART_Popup"> x:Name="PART_Popup">
<Border <Border
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"

View File

@@ -75,8 +75,9 @@
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
Data="M 0,0 L 4,3 L 8,0" Data="M 0,0 L 4,3 L 8,0"
RenderTransformOrigin="0.5,0.5"
Stroke="{DynamicResource TextPrimaryBrush}" Stroke="{DynamicResource TextPrimaryBrush}"
StrokeThickness="1" RenderTransformOrigin="0.5,0.5"> StrokeThickness="1">
<Path.RenderTransform> <Path.RenderTransform>
<RotateTransform Angle="0" /> <RotateTransform Angle="0" />
</Path.RenderTransform> </Path.RenderTransform>
@@ -120,7 +121,65 @@
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Style> </Style>
<!-- 内容样式 -->
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Padding" Value="12,4,8,4" />
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Grid Margin="0,1">
<Border
x:Name="Bd"
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
SnapsToDevicePixels="True">
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<!-- 选中标记 -->
<Border
x:Name="box"
CornerRadius="4"
Visibility="Hidden">
<Border
Width="4"
Margin="2,4"
HorizontalAlignment="Left"
Background="{DynamicResource PrimaryNormalBrush}"
CornerRadius="2" />
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="box" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource ControlBackgroundHoverBrush}" />
</Trigger>
<!--<Trigger Property="IsKeyboardFocused" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource PrimaryFocusedBrush}" />
</Trigger>-->
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 可编辑模板 --> <!-- 可编辑模板 -->
<ControlTemplate x:Key="ComboBoxEditableTemplate" TargetType="{x:Type ComboBox}"> <ControlTemplate x:Key="ComboBoxEditableTemplate" TargetType="{x:Type ComboBox}">
<Grid x:Name="templateRoot" SnapsToDevicePixels="True"> <Grid x:Name="templateRoot" SnapsToDevicePixels="True">
@@ -142,7 +201,7 @@
MinWidth="{Binding ActualWidth, ElementName=templateRoot}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
MaxHeight="{TemplateBinding MaxDropDownHeight}" MaxHeight="{TemplateBinding MaxDropDownHeight}"
Margin="8" Margin="8"
Background="{DynamicResource BackgroundLayoutBrush}" Background="{DynamicResource BackgroundFloatingBrush}"
BorderBrush="{DynamicResource BorderNormalBrush}" BorderBrush="{DynamicResource BorderNormalBrush}"
BorderThickness="1" BorderThickness="1"
CornerRadius="4"> CornerRadius="4">
@@ -179,7 +238,7 @@
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource ComboBoxToggleButton}" /> Style="{StaticResource ComboBoxToggleButton}" />
<!-- 输入框 -->
<Border <Border
x:Name="border" x:Name="border"
Grid.Column="0" Grid.Column="0"
@@ -193,6 +252,7 @@
IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}" IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource FlattenTextBox}" /> Style="{StaticResource FlattenTextBox}" />
</Border> </Border>
<!-- 水印 -->
<TextBlock <TextBlock
x:Name="Placeholder" x:Name="Placeholder"
Margin="{TemplateBinding Padding}" Margin="{TemplateBinding Padding}"
@@ -259,7 +319,7 @@
MinWidth="{Binding ActualWidth, ElementName=templateRoot}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
MaxHeight="{TemplateBinding MaxDropDownHeight}" MaxHeight="{TemplateBinding MaxDropDownHeight}"
Margin="8" Margin="8"
Background="{DynamicResource BackgroundLayoutBrush}" Background="{DynamicResource BackgroundFloatingBrush}"
BorderBrush="{DynamicResource BorderNormalBrush}" BorderBrush="{DynamicResource BorderNormalBrush}"
BorderThickness="1" BorderThickness="1"
CornerRadius="4"> CornerRadius="4">
@@ -371,68 +431,10 @@
</Trigger> </Trigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>
<!-- 默认下拉样式 --> <!-- 默认下拉样式 -->
<Style BasedOn="{StaticResource ComboBoxDefault}" TargetType="{x:Type ComboBox}" /> <Style BasedOn="{StaticResource ComboBoxDefault}" TargetType="{x:Type ComboBox}" />
<!-- 内容样式 -->
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Padding" Value="12,4,8,4" />
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Grid Margin="0,1">
<Border
x:Name="Bd"
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
SnapsToDevicePixels="True">
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<!-- 选中标记 -->
<Border
x:Name="box"
CornerRadius="4"
Visibility="Hidden">
<Border
Width="4"
Margin="2,4"
HorizontalAlignment="Left"
Background="{DynamicResource PrimaryNormalBrush}"
CornerRadius="2" />
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="box" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource BackgroundFloatingBrush}" />
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource PrimaryFocusedBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 工具栏下拉Toggle --> <!-- 工具栏下拉Toggle -->
<Style x:Key="ToolbarComboBoxToggleButton" TargetType="{x:Type ToggleButton}"> <Style x:Key="ToolbarComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
@@ -465,9 +467,10 @@
Grid.Column="1" Grid.Column="1"
HorizontalAlignment="Right" HorizontalAlignment="Right"
VerticalAlignment="Center" VerticalAlignment="Center"
Data="M 0,0 L 4,4 L 0,8 Z" Data="M 0,0 L 4,3 L 8,0"
Fill="{DynamicResource TextPrimaryBrush}" RenderTransformOrigin="0.5,0.5"
RenderTransformOrigin="0.5,0.5"> Stroke="{DynamicResource TextPrimaryBrush}"
StrokeThickness="1">
<Path.RenderTransform> <Path.RenderTransform>
<RotateTransform Angle="0" /> <RotateTransform Angle="0" />
</Path.RenderTransform> </Path.RenderTransform>
@@ -480,7 +483,7 @@
</Trigger> </Trigger>
<!-- 下压效果 --> <!-- 下压效果 -->
<Trigger Property="IsPressed" Value="True"> <Trigger Property="IsPressed" Value="True">
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource PrimaryFocusedBrush}" /> <Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource PrimaryPressedBrush}" />
</Trigger> </Trigger>
<Trigger Property="IsChecked" Value="True"> <Trigger Property="IsChecked" Value="True">
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource PrimaryFocusedBrush}" /> <Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource PrimaryFocusedBrush}" />
@@ -521,7 +524,7 @@
MinWidth="{Binding ActualWidth, ElementName=templateRoot}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
MaxHeight="{TemplateBinding MaxDropDownHeight}" MaxHeight="{TemplateBinding MaxDropDownHeight}"
Margin="8" Margin="8"
Background="{DynamicResource BackgroundContainerBrush}" Background="{DynamicResource BackgroundFloatingBrush}"
BorderBrush="{DynamicResource BorderNormalBrush}" BorderBrush="{DynamicResource BorderNormalBrush}"
BorderThickness="1" BorderThickness="1"
CornerRadius="4"> CornerRadius="4">

View File

@@ -0,0 +1,56 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
namespace NeoUI.Controls
{
public class ContentAdorner : Adorner
{
private readonly Grid _container;
private readonly ContentPresenter _contentPresenter;
private double _offsetY;
public ContentAdorner(UIElement adornedElement, UIElement content) : base(adornedElement)
{
_container = new Grid { Background = Brushes.Transparent };
_contentPresenter = new ContentPresenter { Content = content };
_container.Children.Add(_contentPresenter);
AddLogicalChild(_container);
AddVisualChild(_container);
}
protected override int VisualChildrenCount => 1;
protected override Visual GetVisualChild(int index) => _container;
public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
{
var result = new GeneralTransformGroup();
result.Children.Add(base.GetDesiredTransform(transform));
result.Children.Add(new TranslateTransform(0, _offsetY));
return result;
}
protected override Size MeasureOverride(Size constraint)
{
_container.Measure(constraint);
return _container.DesiredSize;
}
protected override Size ArrangeOverride(Size finalSize)
{
var finalRect = new Rect(new Point(0, 0), finalSize);
if (_contentPresenter.Content is FrameworkElement contentElement)
{
_offsetY = AdornedElement.RenderSize.Height + contentElement.Margin.Top;
}
else
{
_offsetY = AdornedElement.RenderSize.Height;
}
_container.Arrange(finalRect);
return finalSize;
}
}
}

View File

@@ -1,8 +1,9 @@
<ResourceDictionary <ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:svd="clr-namespace:NeoUI.Controls.Decorations" xmlns:decorations="clr-namespace:NeoUI.Controls.Decorations"
xmlns:sve="clr-namespace:NeoUI.Effects" xmlns:sve="clr-namespace:NeoUI.Effects"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:assists="clr-namespace:NeoUI.Assists">
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="CalendarStyle.xaml" /> <ResourceDictionary Source="CalendarStyle.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
@@ -37,7 +38,7 @@
</ControlTemplate.Resources> </ControlTemplate.Resources>
<Grid> <Grid>
<Grid> <Grid>
<svd:SlotBorder <decorations:SlotBorder
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
@@ -54,7 +55,7 @@
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="PART_Watermark" /> x:Name="PART_Watermark" />
</svd:SlotBorder> </decorations:SlotBorder>
<ScrollViewer <ScrollViewer
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
@@ -226,10 +227,11 @@
Opacity="0" Opacity="0"
x:Name="DisabledMask" /> x:Name="DisabledMask" />
<Popup <Popup
assists:PopupAssist.SimulateNativeBehavior="True"
AllowsTransparency="True" AllowsTransparency="True"
Placement="Bottom" Placement="Bottom"
PlacementTarget="{Binding ElementName=PART_Button}" PlacementTarget="{Binding ElementName=PART_Button}"
StaysOpen="False" StaysOpen="True"
x:Name="PART_Popup" /> x:Name="PART_Popup" />
</Grid> </Grid>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>

View File

@@ -2,10 +2,10 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:cvt="clr-namespace:NeoUI.Converters" xmlns:cvt="clr-namespace:NeoUI.Converters"
xmlns:internal="clr-namespace:NeoUI.Converters.Internal" xmlns:internal="clr-namespace:NeoUI.Converters.Internal"
xmlns:svd="clr-namespace:NeoUI.Controls.Decorations" 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">
<Style TargetType="{x:Type svd:EmbossBorder}"> <Style TargetType="{x:Type decorations:EmbossBorder}">
<Setter Property="Focusable" Value="False" /> <Setter Property="Focusable" Value="False" />
<Setter Property="CornerRadius" Value="4" /> <Setter Property="CornerRadius" Value="4" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
@@ -21,7 +21,7 @@
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type svd:EmbossBorder}"> <ControlTemplate TargetType="{x:Type decorations:EmbossBorder}">
<Grid> <Grid>
<!-- 光影区域 --> <!-- 光影区域 -->
<!-- 默认4的边距显示光影效果 --> <!-- 默认4的边距显示光影效果 -->

View File

@@ -10,14 +10,14 @@ namespace NeoUI.Controls.Decorations;
/// </remarks> /// </remarks>
/// <example> /// <example>
/// <code> /// <code>
/// <local:GlassChromeDecorator Width="180" Height="220" /// <controls:GlassChromeDecorator Width="180" Height="220"
/// HorizontalAlignment="Left" VerticalAlignment="Bottom" /// HorizontalAlignment="Left" VerticalAlignment="Bottom"
/// Margin="50" /// Margin="50"
/// CornerRadius="10" /// CornerRadius="10"
/// Background="#40FF0000"> /// Background="#40FF0000">
/// <!-- 半透明红色背景 --> /// <!-- 半透明红色背景 -->
/// <TextBlock Text = "Mini Card" Foreground="White" FontSize="16"/> /// <TextBlock Text = "Mini Card" Foreground="White" FontSize="16"/>
///</local:GlassChromeDecorator> ///</controls:GlassChromeDecorator>
/// </code> /// </code>
/// <![CDATA[]]> /// <![CDATA[]]>
/// </example> /// </example>

View File

@@ -1,9 +1,9 @@
<ResourceDictionary <ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:svd="clr-namespace:NeoUI.Controls.Decorations" 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">
<Style TargetType="{x:Type svd: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" />
@@ -15,7 +15,7 @@
<Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type svd:LightedSurface}"> <ControlTemplate TargetType="{x:Type decorations:LightedSurface}">
<ControlTemplate.Resources> <ControlTemplate.Resources>
<Storyboard x:Key="ShowLight"> <Storyboard x:Key="ShowLight">
<DoubleAnimation <DoubleAnimation

View File

@@ -1,13 +1,13 @@
<ResourceDictionary <ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:local="clr-namespace:NeoUI.Controls" xmlns:controls="clr-namespace:NeoUI.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type local:Divider}"> <Style TargetType="{x:Type controls:Divider}">
<Setter Property="Foreground" Value="{DynamicResource DividerBrush}" /> <Setter Property="Foreground" Value="{DynamicResource DividerBrush}" />
<Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type local:Divider}"> <ControlTemplate TargetType="{x:Type controls:Divider}">
<Grid> <Grid>
<!-- 唯一的水平布局容器,智能且优雅 --> <!-- 唯一的水平布局容器,智能且优雅 -->
<Grid x:Name="HorizontalLayout"> <Grid x:Name="HorizontalLayout">

View File

@@ -38,6 +38,7 @@
<!-- TODO:禁用效果 --> <!-- TODO:禁用效果 -->
<Trigger Property="IsEnabled" Value="false"> <Trigger Property="IsEnabled" Value="false">
<Setter Property="TextElement.Foreground" TargetName="PART_ContentHost" Value="{DynamicResource TextDisabledBrush}" /> <Setter Property="TextElement.Foreground" TargetName="PART_ContentHost" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}"/>
</Trigger> </Trigger>
<Trigger Property="IsMouseOver" Value="true"> <Trigger Property="IsMouseOver" Value="true">

View File

@@ -1,6 +1,6 @@
<ResourceDictionary <ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:svd="clr-namespace:NeoUI.Controls.Decorations" 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">
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Assets/CommonGeometry.xaml" /> <ResourceDictionary Source="../Assets/CommonGeometry.xaml" />
@@ -236,7 +236,7 @@
PlacementTarget="{Binding ElementName=templateRoot}" PlacementTarget="{Binding ElementName=templateRoot}"
PopupAnimation="Fade" PopupAnimation="Fade"
x:Name="PART_Popup"> x:Name="PART_Popup">
<svd:LightedSurface <decorations:LightedSurface
BorderBrush="{DynamicResource BorderGradientBrush}" BorderBrush="{DynamicResource BorderGradientBrush}"
BorderThickness="1" BorderThickness="1"
Effect="{DynamicResource PopupShadow}" Effect="{DynamicResource PopupShadow}"
@@ -265,7 +265,7 @@
</Grid> </Grid>
</ScrollViewer> </ScrollViewer>
</Border> </Border>
</svd:LightedSurface> </decorations:LightedSurface>
</Popup> </Popup>
</Grid> </Grid>
</Border> </Border>
@@ -476,7 +476,7 @@
PopupAnimation="Fade" PopupAnimation="Fade"
VerticalOffset="-3" VerticalOffset="-3"
x:Name="PART_Popup"> x:Name="PART_Popup">
<svd:LightedSurface <decorations:LightedSurface
BorderBrush="{DynamicResource BorderGradientBrush}" BorderBrush="{DynamicResource BorderGradientBrush}"
BorderThickness="1" BorderThickness="1"
Effect="{DynamicResource PopupShadow}" Effect="{DynamicResource PopupShadow}"
@@ -505,7 +505,7 @@
</Grid> </Grid>
</ScrollViewer> </ScrollViewer>
</Border> </Border>
</svd:LightedSurface> </decorations:LightedSurface>
</Popup> </Popup>
</Grid> </Grid>
</Border> </Border>

View File

@@ -10,7 +10,7 @@
x:Class="NeoUI.Controls.ModalWindow" x:Class="NeoUI.Controls.ModalWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:NeoUI.Controls" xmlns:controls="clr-namespace:NeoUI.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Window.Resources> <Window.Resources>

View File

@@ -268,11 +268,11 @@
<!--#endregion--> <!--#endregion-->
</Grid> </Grid>
<Popup <Popup
assists:PopupAssist.SimulateNativeBehavior="True"
x:Name="dropDownBorder" x:Name="dropDownBorder"
MinWidth="{Binding ActualWidth, ElementName=ToggleButton}" MinWidth="{Binding ActualWidth, ElementName=ToggleButton}"
Margin="-8" Margin="-8"
AllowsTransparency="True" AllowsTransparency="True"
Focusable="False"
IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Bottom" Placement="Bottom"
PopupAnimation="Slide" PopupAnimation="Slide"

View File

@@ -3,7 +3,7 @@
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:decorations="clr-namespace:NeoUI.Controls.Decorations" xmlns:decorations="clr-namespace:NeoUI.Controls.Decorations"
xmlns:local="clr-namespace:NeoUI.Controls" xmlns:controls="clr-namespace:NeoUI.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
@@ -37,7 +37,7 @@
</Style.Triggers> </Style.Triggers>
</Style>--> </Style>-->
<Style TargetType="{x:Type local:NumberBox}"> <Style TargetType="{x:Type controls:NumberBox}">
<!--<Setter Property="BorderThickness" Value="1"/>--> <!--<Setter Property="BorderThickness" Value="1"/>-->
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="Padding" Value="2" /> <Setter Property="Padding" Value="2" />
@@ -47,7 +47,7 @@
<Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type local:NumberBox}"> <ControlTemplate TargetType="{x:Type controls:NumberBox}">
<decorations:SlotBorder <decorations:SlotBorder
Padding="{TemplateBinding Padding}" Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"

View File

@@ -2,7 +2,7 @@
<ResourceDictionary <ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:converters="clr-namespace:NeoUI.Converters" xmlns:converters="clr-namespace:NeoUI.Converters"
xmlns:local="clr-namespace:NeoUI.Controls" xmlns:controls="clr-namespace:NeoUI.Controls"
xmlns:decorations="clr-namespace:NeoUI.Controls.Decorations" 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">
@@ -50,7 +50,7 @@
<MultiBinding Converter="{x:Static converters:ComparisionConverter.Instance}"> <MultiBinding Converter="{x:Static converters:ComparisionConverter.Instance}">
<Binding Path="Value" /> <Binding Path="Value" />
<!-- 来自按钮的 DataContext (PageItem.Value) --> <!-- 来自按钮的 DataContext (PageItem.Value) -->
<Binding Path="CurrentPage" RelativeSource="{RelativeSource AncestorType=local:PaginationControl}" /> <Binding Path="CurrentPage" RelativeSource="{RelativeSource AncestorType=controls:PaginationControl}" />
</MultiBinding> </MultiBinding>
</DataTrigger.Binding> </DataTrigger.Binding>
<Setter Property="Visibility" TargetName="emboss" Value="Collapsed" /> <Setter Property="Visibility" TargetName="emboss" Value="Collapsed" />
@@ -67,7 +67,7 @@
<MultiBinding Converter="{x:Static converters:ComparisionConverter.Instance}"> <MultiBinding Converter="{x:Static converters:ComparisionConverter.Instance}">
<Binding Path="Value" /> <Binding Path="Value" />
<!-- 来自按钮的 DataContext (PageItem.Value) --> <!-- 来自按钮的 DataContext (PageItem.Value) -->
<Binding Path="CurrentPage" RelativeSource="{RelativeSource AncestorType=local:PaginationControl}" /> <Binding Path="CurrentPage" RelativeSource="{RelativeSource AncestorType=controls:PaginationControl}" />
</MultiBinding> </MultiBinding>
</DataTrigger.Binding> </DataTrigger.Binding>
<Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" /> <Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
@@ -89,10 +89,10 @@
</Style> </Style>
<!-- PaginationControl 的主模板 --> <!-- PaginationControl 的主模板 -->
<Style TargetType="{x:Type local:PaginationControl}"> <Style TargetType="{x:Type controls:PaginationControl}">
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type local:PaginationControl}"> <ControlTemplate TargetType="{x:Type controls:PaginationControl}">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<!-- 页码按钮列表 --> <!-- 页码按钮列表 -->
<ItemsControl ItemsSource="{Binding PageItems, RelativeSource={RelativeSource TemplatedParent}}"> <ItemsControl ItemsSource="{Binding PageItems, RelativeSource={RelativeSource TemplatedParent}}">
@@ -102,7 +102,7 @@
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ItemsControl.ItemsPanel> </ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type local:PageItem}"> <DataTemplate DataType="{x:Type controls:PageItem}">
<Button <Button
Content="{Binding Text}" Content="{Binding Text}"
IsEnabled="{Binding IsEnabled}" IsEnabled="{Binding IsEnabled}"

View File

@@ -4,7 +4,7 @@
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:converters="clr-namespace:NeoUI.Converters" xmlns:converters="clr-namespace:NeoUI.Converters"
xmlns:svd="clr-namespace:NeoUI.Controls.Decorations"> xmlns:decorations="clr-namespace:NeoUI.Controls.Decorations">
<!--<ResourceDictionary.MergedDictionaries> <!--<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/NeuWPF;component/Controls/TextBoxStyle.xaml" /> <ResourceDictionary Source="pack://application:,,,/NeuWPF;component/Controls/TextBoxStyle.xaml" />
@@ -31,7 +31,7 @@
</Storyboard> </Storyboard>
</ControlTemplate.Resources> </ControlTemplate.Resources>
<svd:SlotBorder <decorations:SlotBorder
x:Name="slot" x:Name="slot"
Padding="{TemplateBinding Padding}" Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
@@ -45,7 +45,7 @@
Focusable="false" Focusable="false"
HorizontalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden" /> VerticalScrollBarVisibility="Hidden" />
</svd:SlotBorder> </decorations:SlotBorder>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<MultiTrigger> <MultiTrigger>
@@ -99,7 +99,7 @@
</Storyboard> </Storyboard>
</ControlTemplate.Resources> </ControlTemplate.Resources>
<Grid> <Grid>
<svd:SlotBorder <decorations:SlotBorder
x:Name="slot" x:Name="slot"
Padding="{TemplateBinding Padding}" Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
@@ -226,7 +226,7 @@
</ToggleButton> </ToggleButton>
</Grid> </Grid>
</svd:SlotBorder> </decorations:SlotBorder>
</Grid> </Grid>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>

View File

@@ -1,7 +1,7 @@
<ResourceDictionary <ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:internal="clr-namespace:NeoUI.Converters.Internal" xmlns:internal="clr-namespace:NeoUI.Converters.Internal"
xmlns:svd="clr-namespace:NeoUI.Controls.Decorations" 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">
<ControlTemplate TargetType="{x:Type ProgressBar}" x:Key="ProgressHorizontalDefault"> <ControlTemplate TargetType="{x:Type ProgressBar}" x:Key="ProgressHorizontalDefault">
@@ -13,7 +13,7 @@
</DoubleAnimationUsingKeyFrames> </DoubleAnimationUsingKeyFrames>
</Storyboard> </Storyboard>
</ControlTemplate.Resources> </ControlTemplate.Resources>
<svd:SlotBorder <decorations:SlotBorder
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
@@ -39,7 +39,7 @@
<Binding <Binding
Mode="OneWay" Mode="OneWay"
Path="ActualWidth" Path="ActualWidth"
RelativeSource="{RelativeSource AncestorType={x:Type svd:SlotBorder}}" /> RelativeSource="{RelativeSource AncestorType={x:Type decorations:SlotBorder}}" />
</MultiBinding> </MultiBinding>
</Grid.Width> </Grid.Width>
<!-- 背景模糊效果 --> <!-- 背景模糊效果 -->
@@ -58,7 +58,7 @@
x:Name="borderProgress" /> x:Name="borderProgress" />
</Grid> </Grid>
</svd:SlotBorder> </decorations:SlotBorder>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsIndeterminate" Value="True"> <Trigger Property="IsIndeterminate" Value="True">
<Setter Property="Width" TargetName="BarGrid" Value="auto" /> <Setter Property="Width" TargetName="BarGrid" Value="auto" />
@@ -103,7 +103,7 @@
</DoubleAnimationUsingKeyFrames> </DoubleAnimationUsingKeyFrames>
</Storyboard> </Storyboard>
</ControlTemplate.Resources> </ControlTemplate.Resources>
<svd:SlotBorder <decorations:SlotBorder
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
@@ -129,7 +129,7 @@
<Binding <Binding
Mode="OneWay" Mode="OneWay"
Path="ActualHeight" Path="ActualHeight"
RelativeSource="{RelativeSource AncestorType={x:Type svd:SlotBorder}}" /> RelativeSource="{RelativeSource AncestorType={x:Type decorations:SlotBorder}}" />
</MultiBinding> </MultiBinding>
</Grid.Height> </Grid.Height>
<!-- 背景模糊效果 --> <!-- 背景模糊效果 -->
@@ -141,7 +141,7 @@
<!-- 进度条 --> <!-- 进度条 -->
<Border Background="{TemplateBinding Foreground}" CornerRadius="3" /> <Border Background="{TemplateBinding Foreground}" CornerRadius="3" />
</Grid> </Grid>
</svd:SlotBorder> </decorations:SlotBorder>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsIndeterminate" Value="True"> <Trigger Property="IsIndeterminate" Value="True">
<Setter Property="Height" TargetName="BarGrid" Value="auto" /> <Setter Property="Height" TargetName="BarGrid" Value="auto" />

View File

@@ -150,7 +150,7 @@
<ControlTemplate TargetType="{x:Type Thumb}"> <ControlTemplate TargetType="{x:Type Thumb}">
<Rectangle <Rectangle
Fill="{DynamicResource ControlStrongBackgroundBrush}" Fill="{DynamicResource TextSecondaryBrush}"
Height="{TemplateBinding Height}" Height="{TemplateBinding Height}"
Margin="6,1,1,1" Margin="6,1,1,1"
RadiusX="1.5" RadiusX="1.5"
@@ -183,7 +183,7 @@
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}"> <ControlTemplate TargetType="{x:Type Thumb}">
<Rectangle <Rectangle
Fill="{DynamicResource ControlStrongBackgroundBrush}" Fill="{DynamicResource TextSecondaryBrush}"
Height="{TemplateBinding Height}" Height="{TemplateBinding Height}"
Margin="1,6,1,1" Margin="1,6,1,1"
RadiusX="1.5" RadiusX="1.5"

View File

@@ -15,7 +15,7 @@
x:Class="NeoUI.Controls.SplashWindow" x:Class="NeoUI.Controls.SplashWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:NeoUI.Controls" xmlns:controls="clr-namespace:NeoUI.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Window.Resources> <Window.Resources>
@@ -87,7 +87,7 @@
</Window.Triggers> </Window.Triggers>
<Grid> <Grid>
<Viewbox <Viewbox
Height="{x:Static local:SplashConfig.ImageHeight}" Height="{x:Static controls:SplashConfig.ImageHeight}"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Name="viewbox" Name="viewbox"
RenderTransformOrigin="0.5,0.5" RenderTransformOrigin="0.5,0.5"
@@ -101,9 +101,9 @@
</TransformGroup> </TransformGroup>
</UIElement.RenderTransform> </UIElement.RenderTransform>
<Grid HorizontalAlignment="Center" VerticalAlignment="Center"> <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<local:Border ClipToBounds="True" CornerRadius="{x:Static local:SplashConfig.CornerRadius}"> <controls:Border ClipToBounds="True" CornerRadius="{x:Static controls:SplashConfig.CornerRadius}">
<Image Source="{Binding ImageUri}" /> <Image Source="{Binding ImageUri}" />
</local:Border> </controls:Border>
</Grid> </Grid>
</Viewbox> </Viewbox>
</Grid> </Grid>

View File

@@ -102,18 +102,14 @@
ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" /> ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" />
<!-- 关闭图标 --> <!-- 关闭图标 为了让触发Close范围足够大而不是只有Path的才能触发套了一层Border-->
<Viewbox <Border
x:Name="PART_Close" x:Name="PART_Close"
Grid.Column="1" Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Background="Transparent"
Focusable="False"
SnapsToDevicePixels="True"
Stretch="Uniform"
UseLayoutRounding="True"
Visibility="Collapsed"> Visibility="Collapsed">
<Viewbox.Style> <Border.Style>
<Style TargetType="{x:Type Viewbox}"> <Style TargetType="{x:Type Border}">
<Setter Property="Opacity" Value="0.65" /> <Setter Property="Opacity" Value="0.65" />
<Setter Property="Margin" Value="2,0,0,0" /> <Setter Property="Margin" Value="2,0,0,0" />
<Style.Triggers> <Style.Triggers>
@@ -123,9 +119,17 @@
</Trigger> </Trigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>
</Viewbox.Style> </Border.Style>
<Viewbox
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Focusable="False"
SnapsToDevicePixels="True"
Stretch="Uniform"
UseLayoutRounding="True">
<Path Data="F1 M1024,1024z M0,0z M578.36284173,512L1000.67183457,89.69100716C1018.7707914,71.59205033 1018.7707914,41.42712226 1000.67183457,23.32816543 982.57287774,5.22920860000003 952.40794967,5.22920860000003 934.30899284,23.32816543L512,445.63715827 89.69100716,23.32816543C71.59205033,5.22920860000001 41.42712226,5.22920860000001 23.32816543,23.32816543 5.22920860000003,41.42712226 5.22920860000003,71.59205033 23.32816543,89.69100716L445.63715827,512 23.32816543,934.30899284C5.22920860000001,952.40794967 5.22920860000001,982.57287774 23.32816543,1000.67183457 41.42712226,1018.7707914 71.59205033,1018.7707914 89.69100716,1000.67183457L512,578.36284173 934.30899284,1000.67183457C952.40794967,1018.7707914 982.57287774,1018.7707914 1000.67183457,1000.67183457 1018.7707914,982.57287774 1018.7707914,952.40794967 1000.67183457,934.30899284L578.36284173,512z" Fill="{TemplateBinding Foreground}" /> <Path Data="F1 M1024,1024z M0,0z M578.36284173,512L1000.67183457,89.69100716C1018.7707914,71.59205033 1018.7707914,41.42712226 1000.67183457,23.32816543 982.57287774,5.22920860000003 952.40794967,5.22920860000003 934.30899284,23.32816543L512,445.63715827 89.69100716,23.32816543C71.59205033,5.22920860000001 41.42712226,5.22920860000001 23.32816543,23.32816543 5.22920860000003,41.42712226 5.22920860000003,71.59205033 23.32816543,89.69100716L445.63715827,512 23.32816543,934.30899284C5.22920860000001,952.40794967 5.22920860000001,982.57287774 23.32816543,1000.67183457 41.42712226,1018.7707914 71.59205033,1018.7707914 89.69100716,1000.67183457L512,578.36284173 934.30899284,1000.67183457C952.40794967,1018.7707914 982.57287774,1018.7707914 1000.67183457,1000.67183457 1018.7707914,982.57287774 1018.7707914,952.40794967 1000.67183457,934.30899284L578.36284173,512z" Fill="{TemplateBinding Foreground}" />
</Viewbox> </Viewbox>
</Border>
</Grid> </Grid>
</Border> </Border>
</Grid> </Grid>

View File

@@ -3,7 +3,7 @@
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:converters="clr-namespace:NeoUI.Converters" xmlns:converters="clr-namespace:NeoUI.Converters"
xmlns:svd="clr-namespace:NeoUI.Controls.Decorations" 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">
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/NeoUI;component/Controls/IconElement.xaml" /> <ResourceDictionary Source="pack://application:,,,/NeoUI;component/Controls/IconElement.xaml" />
@@ -77,7 +77,7 @@
</ControlTemplate.Resources> </ControlTemplate.Resources>
<Grid> <Grid>
<svd:SlotBorder <decorations:SlotBorder
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
@@ -85,7 +85,7 @@
Margin="-4" Margin="-4"
SnapsToDevicePixels="True" SnapsToDevicePixels="True"
x:Name="slot" /> x:Name="slot" />
<svd:EmbossBorder <decorations:EmbossBorder
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
@@ -270,7 +270,7 @@
</Storyboard> </Storyboard>
</ControlTemplate.Resources> </ControlTemplate.Resources>
<svd:SlotBorder <decorations:SlotBorder
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
@@ -336,7 +336,7 @@
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="Suffix" /> x:Name="Suffix" />
</Grid> </Grid>
</svd:SlotBorder> </decorations:SlotBorder>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<DataTrigger Binding="{Binding Text, Mode=OneWay, RelativeSource={RelativeSource Self}}" Value=""> <DataTrigger Binding="{Binding Text, Mode=OneWay, RelativeSource={RelativeSource Self}}" Value="">
@@ -462,7 +462,7 @@
To="0.2" /> To="0.2" />
</Storyboard> </Storyboard>
</ControlTemplate.Resources> </ControlTemplate.Resources>
<svd:SlotBorder <decorations:SlotBorder
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
@@ -479,7 +479,7 @@
IsTabStop="False" IsTabStop="False"
VerticalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"
x:Name="PART_ContentHost" /> x:Name="PART_ContentHost" />
</svd:SlotBorder> </decorations:SlotBorder>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False"> <Trigger Property="IsEnabled" Value="False">

View File

@@ -3,7 +3,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:NeoUI.Controls"
xmlns:controls="clr-namespace:NeoUI.Controls" xmlns:controls="clr-namespace:NeoUI.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Width="320" Width="320"

View File

@@ -3,7 +3,7 @@
xmlns:assist="clr-namespace:NeoUI.Assists" xmlns:assist="clr-namespace:NeoUI.Assists"
xmlns:converters="clr-namespace:NeoUI.Converters" xmlns:converters="clr-namespace:NeoUI.Converters"
xmlns:internal="clr-namespace:NeoUI.Converters.Internal" xmlns:internal="clr-namespace:NeoUI.Converters.Internal"
xmlns:svd="clr-namespace:NeoUI.Controls.Decorations" 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">
<Style TargetType="{x:Type ToggleButton}" x:Key="NeuToggleSwitch"> <Style TargetType="{x:Type ToggleButton}" x:Key="NeuToggleSwitch">
@@ -38,7 +38,7 @@
Visibility="Collapsed" Visibility="Collapsed"
x:Name="AnimationProxy" /> x:Name="AnimationProxy" />
<!-- 背景层 --> <!-- 背景层 -->
<svd:SlotBorder <decorations:SlotBorder
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
CornerRadius="{Binding Path=ActualHeight, ElementName=SwitchContainer, Converter={x:Static converters:DivideByTwoConverter.Instance}}" CornerRadius="{Binding Path=ActualHeight, ElementName=SwitchContainer, Converter={x:Static converters:DivideByTwoConverter.Instance}}"
Intensity="0.3" Intensity="0.3"
@@ -97,7 +97,7 @@
</TranslateTransform.X> </TranslateTransform.X>
</TranslateTransform> </TranslateTransform>
</Grid.RenderTransform> </Grid.RenderTransform>
<svd:EmbossBorder <decorations:EmbossBorder
Background="{DynamicResource PrimaryNormalBrush}" Background="{DynamicResource PrimaryNormalBrush}"
CornerRadius="{Binding Path=ActualHeight, ElementName=SwitchContainer, Converter={x:Static converters:DivideByTwoConverter.Instance}}" CornerRadius="{Binding Path=ActualHeight, ElementName=SwitchContainer, Converter={x:Static converters:DivideByTwoConverter.Instance}}"
Intensity="0.5" Intensity="0.5"
@@ -105,7 +105,7 @@
Padding="0" Padding="0"
x:Name="circle"> x:Name="circle">
<!--<Ellipse x:Name="optionMark" Fill="{DynamicResource PrimaryNormalBrush}" />--> <!--<Ellipse x:Name="optionMark" Fill="{DynamicResource PrimaryNormalBrush}" />-->
</svd:EmbossBorder> </decorations:EmbossBorder>
</Grid> </Grid>
<TextBlock <TextBlock
Foreground="{DynamicResource TextPrimaryBrush}" Foreground="{DynamicResource TextPrimaryBrush}"
@@ -208,13 +208,13 @@
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}"> <ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid> <Grid>
<svd:EmbossBorder <decorations:EmbossBorder
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
Intensity="0.6" Intensity="0.6"
Margin="0" Margin="0"
ShaderEnabled="True" ShaderEnabled="True"
x:Name="border" /> x:Name="border" />
<svd:SlotBorder <decorations:SlotBorder
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
Intensity="0" Intensity="0"
Margin="0" Margin="0"
@@ -228,7 +228,7 @@
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="contentPresenter" /> x:Name="contentPresenter" />
</svd:SlotBorder> </decorations:SlotBorder>
</Grid> </Grid>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
@@ -459,8 +459,7 @@
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True"> <Trigger Property="IsChecked" Value="True">
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{DynamicResource TextInverseBrush}" /> <Setter Property="Background" TargetName="border" Value="{DynamicResource ControlBackgroundSelectedBrush}" />
<Setter Property="Background" TargetName="border" Value="{DynamicResource ControlBackgroundPressedBrush}" />
</Trigger> </Trigger>
<Trigger Property="Button.IsDefaulted" Value="True" /> <Trigger Property="Button.IsDefaulted" Value="True" />
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">

View File

@@ -1,7 +1,7 @@
<ResourceDictionary <ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:converters="clr-namespace:NeoUI.Converters" xmlns:converters="clr-namespace:NeoUI.Converters"
xmlns:local="clr-namespace:NeoUI.Controls" xmlns:controls="clr-namespace:NeoUI.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="Button" x:Key="DeleteButtonStyle"> <Style TargetType="Button" x:Key="DeleteButtonStyle">
@@ -30,15 +30,15 @@
</Setter> </Setter>
</Style> </Style>
<Style TargetType="{x:Type local:UploadArea}"> <Style TargetType="{x:Type controls:UploadArea}">
<Setter Property="AllowDrop" Value="True" /> <Setter Property="AllowDrop" Value="True" />
<Setter Property="Background" Value="Transparent" /> <Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="BorderThickness" Value="0" /> <Setter Property="BorderThickness" Value="0" />
<Setter Property="Padding" Value="8" /> <!--<Setter Property="Padding" Value="8" />-->
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type local:UploadArea}"> <ControlTemplate TargetType="{x:Type controls:UploadArea}">
<Grid> <Grid>
<StackPanel> <StackPanel>
<!-- 上传区域 --> <!-- 上传区域 -->
@@ -54,13 +54,11 @@
<Border <Border
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="1" BorderThickness="1"
CornerRadius="2" CornerRadius="4"
Padding="16" Padding="16"
x:Name="DropAreaBorder"> x:Name="DropAreaBorder">
<Border.Style> <Border.Style>
<Style TargetType="Border"> <Style TargetType="Border">
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<!--<Setter Property="BorderDashArray" Value="4 4"/>-->
<Style.Triggers> <Style.Triggers>
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
@@ -93,7 +91,7 @@
<!-- 已选文件列表 --> <!-- 已选文件列表 -->
<ItemsControl ItemsSource="{TemplateBinding FileList}" Margin="0,8,0,0"> <ItemsControl ItemsSource="{TemplateBinding FileList}" Margin="0,8,0,0">
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type local:UploadFileItem}"> <DataTemplate DataType="{x:Type controls:UploadFileItem}">
<Border <Border
Background="{DynamicResource BackgroundLayoutBrush}" Background="{DynamicResource BackgroundLayoutBrush}"
BorderBrush="{DynamicResource BorderNormalBrush}" BorderBrush="{DynamicResource BorderNormalBrush}"
@@ -128,7 +126,7 @@
VerticalAlignment="Center" /> VerticalAlignment="Center" />
<Button <Button
Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:UploadArea}}, Path=RemoveItemCommand}" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:UploadArea}}, Path=RemoveItemCommand}"
CommandParameter="{Binding}" CommandParameter="{Binding}"
Grid.Column="2" Grid.Column="2"
Style="{StaticResource DeleteButtonStyle}" /> Style="{StaticResource DeleteButtonStyle}" />

View File

@@ -42,8 +42,8 @@ namespace NeoUI.Markup
/// <summary> /// <summary>
/// 在ResourceDictionary中声明 /// 在ResourceDictionary中声明
/// </summary> /// </summary>
/// <example><c>local:EnumSourceExtension x:Key="EnumBindingSource" EnumType="{x:AppearanceType local:Sex}"</c></example> /// <example><c>controls:EnumSourceExtension x:Key="EnumBindingSource" EnumType="{x:AppearanceType controls:Sex}"</c></example>
/// <example><c>ItemsSource="{local:EnumSource EnumType=local:ExampleEnum}" SelectedItem="{Binding ExampleEnum}"</c></example> /// <example><c>ItemsSource="{controls:EnumSource EnumType=controls:ExampleEnum}" SelectedItem="{Binding ExampleEnum}"</c></example>
public EnumSourceExtension() public EnumSourceExtension()
{ {
@@ -53,7 +53,7 @@ namespace NeoUI.Markup
/// </summary> /// </summary>
/// <param name="enumType"></param> /// <param name="enumType"></param>
/// <remarks>若需要绑定Description则需设置BindToDescription为True同时只能用SelectedValue来绑定源属性</remarks> /// <remarks>若需要绑定Description则需设置BindToDescription为True同时只能用SelectedValue来绑定源属性</remarks>
/// <example><c>ItemsSource="{Binding Source={local:EnumTypeBindingSource {x:AppearanceType local:ExampleEnum}}}"</c></example> /// <example><c>ItemsSource="{Binding Source={controls:EnumTypeBindingSource {x:AppearanceType controls:ExampleEnum}}}"</c></example>
public EnumSourceExtension(Type enumType) { EnumType = enumType; } public EnumSourceExtension(Type enumType) { EnumType = enumType; }
/// <inheritdoc /> /// <inheritdoc />

View File

@@ -23,7 +23,7 @@
<Color x:Key="PrimaryFocusedColor">#82B1FF</Color> <Color x:Key="PrimaryFocusedColor">#82B1FF</Color>
<SolidColorBrush x:Key="PrimaryFocusedBrush" Color="{DynamicResource PrimaryFocusedColor}" /> <SolidColorBrush x:Key="PrimaryFocusedBrush" Color="{DynamicResource PrimaryFocusedColor}" />
<Color x:Key="PrimaryDisabledColor">#B3C6FF</Color> <Color x:Key="PrimaryDisabledColor">#727EA3</Color>
<SolidColorBrush x:Key="PrimaryDisabledBrush" Color="{DynamicResource PrimaryDisabledColor}" /> <SolidColorBrush x:Key="PrimaryDisabledBrush" Color="{DynamicResource PrimaryDisabledColor}" />
<!-- <!--

View File

@@ -194,7 +194,7 @@
<Color x:Key="TextSecondaryColor">#6d7a7d</Color> <Color x:Key="TextSecondaryColor">#6d7a7d</Color>
<Color x:Key="TextDisabledColor">#767676</Color> <Color x:Key="TextDisabledColor">#767676</Color>
<Color x:Key="TextInverseColor">#1C1E22</Color> <Color x:Key="TextInverseColor">#1C1E22</Color>
<Color x:Key="TextPlaceholderColor">#595b60</Color> <Color x:Key="TextPlaceholderColor">#7B7E85</Color>
<SolidColorBrush x:Key="TextPrimaryBrush" Color="{DynamicResource TextPrimaryColor}" /> <SolidColorBrush x:Key="TextPrimaryBrush" Color="{DynamicResource TextPrimaryColor}" />
<SolidColorBrush x:Key="TextSecondaryBrush" Color="{DynamicResource TextSecondaryColor}" /> <SolidColorBrush x:Key="TextSecondaryBrush" Color="{DynamicResource TextSecondaryColor}" />

View File

@@ -574,22 +574,22 @@
<n:ChooseBox Placeholder="请选择路径" /> <n:ChooseBox Placeholder="请选择路径" />
<n:ChooseBox IsEnabled="False" Text="选择路径" /> <n:ChooseBox IsEnabled="False" Text="选择路径" />
</n:FlexibleRowPanel> </n:FlexibleRowPanel>
<n:FlexibleRowPanel> <UniformGrid Rows="2" >
<n:UploadArea <n:UploadArea Margin="5"
Accept="Image Files|*.jpg;*.jpeg;*.png;*.gif|All Files|*.*" Accept="Image Files|*.jpg;*.jpeg;*.png;*.gif|All Files|*.*"
HintText="点击选择单个图片" HintText="点击选择单个图片"
Mode="FilesOnly" /> Mode="FilesOnly" />
<n:UploadArea HintText="点击选择一个项目文件夹" Mode="FoldersOnly" /> <n:UploadArea Margin="5" HintText="点击选择一个项目文件夹" Mode="FoldersOnly" />
<n:UploadArea <n:UploadArea Margin="5"
Accept="Document Files|*.doc;*.docx;*.pdf|All Files|*.*" Accept="Document Files|*.doc;*.docx;*.pdf|All Files|*.*"
HintText="点击或拖拽多个文档到此" HintText="点击或拖拽多个文档到此"
Mode="FilesOnly" Mode="FilesOnly"
Multiple="True" /> Multiple="True" />
<n:UploadArea <n:UploadArea Margin="5"
HintText="点击或拖拽多个文件夹到此" HintText="点击或拖拽多个文件夹到此"
Mode="FoldersOnly" Mode="FoldersOnly"
Multiple="True" /> Multiple="True" />
</n:FlexibleRowPanel> </UniformGrid>
</StackPanel> </StackPanel>
<StackPanel n:AnchorAssist.Header="下拉框 ComboBox"> <StackPanel n:AnchorAssist.Header="下拉框 ComboBox">
<n:FlexibleRowPanel Spacing="5"> <n:FlexibleRowPanel Spacing="5">