using Avalonia.Input;
using Avalonia.Interactivity;
namespace Avalonia.Xaml.Interactions.Events;
///
///
///
public abstract class KeyDownEventBehavior : InteractiveBehaviorBase
{
static KeyDownEventBehavior()
{
RoutingStrategiesProperty.OverrideMetadata(
new StyledPropertyMetadata(
defaultValue: RoutingStrategies.Tunnel | RoutingStrategies.Bubble));
}
///
protected override void OnAttachedToVisualTree()
{
AssociatedObject?.AddHandler(InputElement.KeyDownEvent, KeyDown, RoutingStrategies);
}
///
protected override void OnDetachedFromVisualTree()
{
AssociatedObject?.RemoveHandler(InputElement.KeyDownEvent, KeyDown);
}
private void KeyDown(object? sender, KeyEventArgs e)
{
OnKeyDown(sender, e);
}
///
///
///
///
///
protected virtual void OnKeyDown(object? sender, KeyEventArgs e)
{
}
}