Убраны синхронные методы

This commit is contained in:
2026-01-25 01:52:03 +03:00
parent 79bdd8bc62
commit a6ee6fcb36
22 changed files with 1108 additions and 2137 deletions

View File

@@ -0,0 +1,49 @@
using Microsoft.UI.Xaml;
namespace Lattice.UI.DragDrop.WinUI.Behaviors;
/// <summary>
/// Attached properties для DragSource.
/// </summary>
public static class DragSource
{
public static readonly DependencyProperty IsEnabledProperty =
DependencyProperty.RegisterAttached(
"IsEnabled",
typeof(bool),
typeof(DragSource),
new PropertyMetadata(false, OnIsEnabledChanged));
public static readonly DependencyProperty DragDataProperty =
DependencyProperty.RegisterAttached(
"DragData",
typeof(object),
typeof(DragSource),
new PropertyMetadata(null));
public static bool GetIsEnabled(UIElement element) =>
(bool)element.GetValue(IsEnabledProperty);
public static void SetIsEnabled(UIElement element, bool value) =>
element.SetValue(IsEnabledProperty, value);
public static object GetDragData(UIElement element) =>
element.GetValue(DragDataProperty);
public static void SetDragData(UIElement element, object value) =>
element.SetValue(DragDataProperty, value);
private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is not UIElement element) return;
// TODO: Здесь нужно создать экземпляр WinUIDragSourceBehavior
// и прикрепить его к элементу через DI
// Пока что устанавливаем данные в Tag
if ((bool)e.NewValue)
{
var data = GetDragData(element);
element.Tag = data;
}
}
}