mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
34 lines
824 B
C#
34 lines
824 B
C#
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using Microsoft.Xaml.Behaviors;
|
|
|
|
namespace Artemis.UI.Shared
|
|
{
|
|
public class PutCursorAtEndTextBox : Behavior<UIElement>
|
|
{
|
|
private TextBox _textBox;
|
|
|
|
protected override void OnAttached()
|
|
{
|
|
base.OnAttached();
|
|
|
|
_textBox = AssociatedObject as TextBox;
|
|
|
|
if (_textBox == null) return;
|
|
_textBox.GotFocus += TextBoxGotFocus;
|
|
}
|
|
|
|
protected override void OnDetaching()
|
|
{
|
|
if (_textBox == null) return;
|
|
_textBox.GotFocus -= TextBoxGotFocus;
|
|
|
|
base.OnDetaching();
|
|
}
|
|
|
|
private void TextBoxGotFocus(object sender, RoutedEventArgs routedEventArgs)
|
|
{
|
|
_textBox.CaretIndex = _textBox.Text.Length;
|
|
}
|
|
}
|
|
} |