WinUI 3 | Align NumberBox using the VisualTreeHelper | XAML | C# | .NET | UWP | WPF

Опубликовано: 20 Март 2026
на канале: Andrew KeepCoding
1,114
26

Update: Fixed cursor position when the value is deleted.
https://github.com/AndrewKeepCoding/C...

Usually, numbers in the NumberBox are easier to read when they are right-aligned. But unfortunately, the NumberBox's TextAlignment is still in Preview. In this video we'll see how to cheat this using the VisualTreeHelper.

GitHub repo:
https://github.com/AndrewKeepCoding/C...

NumberBox issue on GitHub:
https://github.com/microsoft/microsof...

VisualTreeHelper:
https://docs.microsoft.com/en-us/dotn...

Chapters:
00:00 Intro
00:17 NumberBox issue on GitHub repo
00:28 Left-aligned NumberBox
00:40 WinUI 3 Class Reference app (work in progress)
01:27 NumberBox components
01:44 FindChildrenOfType method
02:16 Overriding ScrollViewer [ContentElement]
03:17 Overriding RepeatButtons [UpSpinButton/DownSpinButton]
05:47 Ending

Twitter:
  / andrewkeepcodin  

#winui3 #numberbox #visualtreehelper