|
|
|
@ -6,7 +6,9 @@ using Avalonia.Controls; |
|
|
|
using Avalonia.Markup.Xaml; |
|
|
|
using ControlCatalog.Models; |
|
|
|
using Avalonia.Collections; |
|
|
|
using Avalonia.Controls.Primitives; |
|
|
|
using Avalonia.Data; |
|
|
|
using Avalonia.Threading; |
|
|
|
|
|
|
|
namespace ControlCatalog.Pages |
|
|
|
{ |
|
|
|
@ -84,5 +86,19 @@ namespace ControlCatalog.Pages |
|
|
|
return Comparer.Default.Compare(x, y); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void NumericUpDown_OnTemplateApplied(object sender, TemplateAppliedEventArgs e) |
|
|
|
{ |
|
|
|
// We want to focus the TextBox of the NumericUpDown. To do so we search for this control when the template
|
|
|
|
// is applied, but we postpone the action until the control is actually loaded.
|
|
|
|
if (e.NameScope.Find<TextBox>("PART_TextBox") is {} textBox) |
|
|
|
{ |
|
|
|
Dispatcher.UIThread.InvokeAsync(() => |
|
|
|
{ |
|
|
|
textBox.Focus(); |
|
|
|
textBox.SelectAll(); |
|
|
|
}, DispatcherPriority.Loaded); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|