mirror of
https://github.com/VitalickS/BrightSharp.Toolkit.git
synced 2026-03-21 18:31:17 +00:00
Diagram Rotate thumb optional through VisualExtensions, 1 new behavior, BrightSharpWindowStyle release candidate, style.blue fix, TabControl + leadingelement, Expander toggle on full header width
34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
using System.Windows.Controls.Primitives;
|
|
using System.Windows.Input;
|
|
using System.Windows.Interactivity;
|
|
|
|
namespace BrightSharp.Behaviors
|
|
{
|
|
public class SelectAllTextOnFocusBehavior : Behavior<TextBoxBase>
|
|
{
|
|
protected override void OnAttached() {
|
|
base.OnAttached();
|
|
AssociatedObject.GotKeyboardFocus += AssociatedObjectGotKeyboardFocus;
|
|
AssociatedObject.PreviewMouseLeftButtonDown += AssociatedObjectPreviewMouseLeftButtonDown;
|
|
}
|
|
|
|
protected override void OnDetaching() {
|
|
base.OnDetaching();
|
|
AssociatedObject.GotKeyboardFocus -= AssociatedObjectGotKeyboardFocus;
|
|
AssociatedObject.PreviewMouseLeftButtonDown -= AssociatedObjectPreviewMouseLeftButtonDown;
|
|
}
|
|
|
|
private void AssociatedObjectGotKeyboardFocus(object sender,
|
|
KeyboardFocusChangedEventArgs e) {
|
|
AssociatedObject.SelectAll();
|
|
}
|
|
|
|
private void AssociatedObjectPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) {
|
|
if (!AssociatedObject.IsKeyboardFocusWithin) {
|
|
AssociatedObject.Focus();
|
|
e.Handled = true;
|
|
}
|
|
}
|
|
}
|
|
}
|