mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
思维导图修改成回车新增子节点
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xaml.Behaviors;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class TextBoxEnterKeyUpdateBehavior : Behavior<TextBox>
|
||||
{
|
||||
protected override void OnAttached()
|
||||
{
|
||||
if (this.AssociatedObject != null)
|
||||
{
|
||||
base.OnAttached();
|
||||
this.AssociatedObject.KeyDown += AssociatedObject_KeyDown;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDetaching()
|
||||
{
|
||||
if (this.AssociatedObject != null)
|
||||
{
|
||||
this.AssociatedObject.KeyDown -= AssociatedObject_KeyDown;
|
||||
base.OnDetaching();
|
||||
}
|
||||
}
|
||||
|
||||
private void AssociatedObject_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
||||
{
|
||||
TextBox textBox = sender as TextBox;
|
||||
if (textBox != null)
|
||||
{
|
||||
if (e.Key == Key.Return)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
textBox.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user