mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using System.Windows;
|
|
using System.Windows.Input;
|
|
|
|
namespace Artemis.UI.Behaviors
|
|
{
|
|
public class MouseBehavior
|
|
{
|
|
public static readonly DependencyProperty MouseUpCommandProperty =
|
|
DependencyProperty.RegisterAttached("MouseUpCommand", typeof(ICommand),
|
|
typeof(MouseBehavior), new FrameworkPropertyMetadata(
|
|
MouseUpCommandChanged));
|
|
|
|
public static void SetMouseUpCommand(UIElement element, ICommand value)
|
|
{
|
|
element.SetValue(MouseUpCommandProperty, value);
|
|
}
|
|
|
|
public static ICommand GetMouseUpCommand(UIElement element)
|
|
{
|
|
return (ICommand) element.GetValue(MouseUpCommandProperty);
|
|
}
|
|
|
|
private static void MouseUpCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
FrameworkElement element = (FrameworkElement) d;
|
|
|
|
element.MouseUp += element_MouseUp;
|
|
}
|
|
|
|
private static void element_MouseUp(object sender, MouseButtonEventArgs e)
|
|
{
|
|
FrameworkElement element = (FrameworkElement) sender;
|
|
|
|
ICommand command = GetMouseUpCommand(element);
|
|
|
|
command.Execute(e);
|
|
}
|
|
}
|
|
} |