refactor: 将Framework库和RT、UI放在同一个解决方案中。

This commit is contained in:
SL
2026-06-01 17:48:28 +08:00
parent 1948f4290d
commit b73d39a6b1
4331 changed files with 506148 additions and 49363 deletions
@@ -0,0 +1,54 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace WpfStyleableWindow.StyleableWindow
{
public static class ControlDoubleClickBehavior
{
public static readonly DependencyProperty ExecuteCommand = DependencyProperty.RegisterAttached("ExecuteCommand", typeof(ICommand), typeof(ControlDoubleClickBehavior), new UIPropertyMetadata(null, OnExecuteCommandChanged));
public static readonly DependencyProperty ExecuteCommandParameter = DependencyProperty.RegisterAttached("ExecuteCommandParameter", typeof(Window), typeof(ControlDoubleClickBehavior));
public static ICommand GetExecuteCommand(DependencyObject obj)
{
return (ICommand)obj.GetValue(ExecuteCommand);
}
public static void SetExecuteCommand(DependencyObject obj, ICommand command)
{
obj.SetValue(ExecuteCommand, command);
}
public static Window GetExecuteCommandParameter(DependencyObject obj)
{
return (Window)obj.GetValue(ExecuteCommandParameter);
}
public static void SetExecuteCommandParameter(DependencyObject obj, ICommand command)
{
obj.SetValue(ExecuteCommandParameter, command);
}
private static void OnExecuteCommandChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (sender is Control control)
{
control.MouseDoubleClick += control_MouseDoubleClick;
}
}
private static void control_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (sender is Control control)
{
ICommand command = control.GetValue(ExecuteCommand) as ICommand;
object value = control.GetValue(ExecuteCommandParameter);
if (command.CanExecute(e))
{
command.Execute(value);
}
}
}
}
}