When one does not specify a header for the NumberBox control, it still takes up a bit of space, despite it shouldn't. The following XAML snippet generates the following output:
<StackPanel Orientation="Horizontal">
<TextBox Height="30"/>
<muxc:NumberBox Height="30"/>
</StackPanel>
WinUI version: 2.4.0-prerelease.200203002
The TextBlock likely takes up layout space even when there is no content. We could fix it by collapsing it the TextBlock in this case, but this looks like a general issue with TextBlock ?
Marcel, can you file a separate issue on TextBlock ?
The problem I was trying to outline is the fact that the Header of our NumberBox takes up space. Thats why those two controls are not aligned correctly. From debugging that, it seems that the header has a 3px bottom margin, which is still being applied even if the header is not used, thus we have the gap here.
I see. That makes sense.
I can take this issue, if that's okay.
Probably worth Delay/Lazy loading the header too like most of the other framework controls?
@JohnnyWestlake What exactly do you mean by delay/lazy loading the header? Do you have a control at hand, which currently does this? 😅
@JohnnyWestlake do you mean use x:Load
?
Oh, yes I see. I will add the x:DeferLoadStrategy
to the header property of the NumberBox with that PR to align with other control's headers.
Starting in Windows 10, version 1703 (Creators Update), x:DeferLoadStrategy is superseded by the x:Load attribute. Using x:Load="False" is equivalent to x:DeferLoadStrategy="Lazy", but provides the ability to unload the UI if required. See the x:Load attribute for more info.
(https://docs.microsoft.com/en-us/windows/uwp/xaml-platform/x-deferloadstrategy-attribute)
What is the reason x:Load is not used here? It's available since 1703 which is the required minimum version an app consuming WinUI 2 needs to target.
The WinUI repo is not consistent here, some controls use x:Load, others use x:DeferLoadStrategy.
You might want to create an issue for this, since it might be better to only use x:Load instead of x:DeferLoadStrategy
@chingucoding Why are you deciding not to use x:Load here but instead older API? Is there precedence in NumberBox which is why you use x:DeferLoadStrategy? Otherwise, why not use x:Load?
@chingucoding Why are you deciding not to use x:Load here but instead older API? Is there precedence in NumberBox which is why you use x:DeferLoadStrategy? Otherwise, why not use x:Load?
Simply to stay consistent within the file. Changing API's of areas that are not affected by this bug is not ideal, that's why for now I would like to keep the NumberBox files consistent. Changing from xDeferLoadStrategy to x:Load is something that needs to be done throughout multiple files within the project and thus should be a separate issue and PR.
Edit: @Felix-Dev correctly told me that both are being used inside the NumberBox, making the consistency argument less valid. However TextBox and RIchEditBox, which the Header behavior was copied from, do use x:DeferLoadStrategy.
Most helpful comment
I can take this issue, if that's okay.