添加项目文件。

This commit is contained in:
GG Z
2024-09-22 11:05:41 +08:00
parent fb5d55723a
commit 49ceaae6a8
764 changed files with 78850 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
using System.Windows;
using Microsoft.Xaml.Behaviors;
/// <summary>
/// 拖拽文件事件
/// </summary>
/// <example>DropFileBehaviors Data="{Binding FileNames,Mode=OneWayToSource}"从依赖属性传到源属性通过源属性实现Mvvm</example>
/// <remarks>设置窗口属性AllowDrop在上层覆盖一个面板如Grid设置窗口的DropEnter和DropLeave(EventTrigger)事件控制其显隐以及控制Drop事件后隐藏(ChangePropertyAction)</remarks>
class DropFileBehavior : Behavior<FrameworkElement>
{
public string[] Data
{
get { return (string[])GetValue(DataProperty); }
set { SetValue(DataProperty, value); }
}
public static readonly DependencyProperty DataProperty =
DependencyProperty.Register(nameof(Data), typeof(string[]), typeof(DropFileBehavior), new PropertyMetadata(null));
protected override void OnAttached()
{
AssociatedObject.AllowDrop = true;
AssociatedObject.Drop += DropHandler;
}
private void DropHandler(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
Data = (string[])e.Data.GetData(DataFormats.FileDrop);
}
}
protected override void OnDetaching()
{
AssociatedObject.Drop -= DropHandler;
}
protected override void OnChanged()
{
base.OnChanged();
}
}