-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StackPanel applies Spacing to Collapsed items #916
Comments
I just ran across this one myself. Definitely would be a big help to fix this for cases where items are dynamically shown/hidden in a StackPanel. |
I would definitely love to see this behavior adjusted. Maybe it could be controlled by a separate property like |
This is more of a bug. I wouldn't advocate adding a new property to control this. Concerns about changing existing apps would be trivial. The change is non-breaking and would only slightly affect the look of some (an extremely small number) of apps. |
@robloo I am afraid people who come across this have actually employed some "hacks" to work around this (like negative margins), so it would be a breaking change. But it is probably an acceptable one. For |
Non-breaking to me means the app will still compile, build and run without errors or crash. Of course visually these are differences but there are also differences when styling is updated from time to time. I agree that it is acceptable reguardless. |
Just ran across this when trying out the |
I'm adding my |
Since there doesn't seem to be an official fix for the problem, I created a new implementation which inherits from StackPanel. My version uses margins to create spacing between items in the StackPanel, but only for those items which are visible. Full implemenation: StackPanelWithSpacing private void SetSpacingForChildren(int spacing)
{
for (int i = 0; i < this.Children.Count; i++)
{
if (this.Children[i] is FrameworkElement element
&& element.Visibility == Visibility.Visible)
{
var halfSpacing = spacing / 2;
var topSpacing = i == 0 ? 0 : halfSpacing;
element.Margin = new Thickness(element.Margin.Left, element.Margin.Top + topSpacing, element.Margin.Right, element.Margin.Bottom + halfSpacing);
}
}
} |
two years has passed, issue should be closed if not planned. |
I'd like to see this change, I've never been able to use the Spacing property due to this, and I would use it often otherwise. |
This is a "one minute fix" (replicating @tomtom-m code). Please... |
I wasted some time on this today, is there any chance this bug will be fixed after 3.5 years? |
This is the With WinUI3 out for a while now, when will this issue (and many others with |
@trungnt2910 Begin transition to other UI frameworks. Microsoft is killing this off for anyone but the OS team and C++ apps. I would even go as far as to say it will never be open sourced (contrary to what they will publicly state) so the community will never be able to fix issues like these. If you are using C# Avalonia will be dominant in a few years, it is already dominant in most scenarios. Microsoft is repeating the same failures here with WinUI3 we've seen many times before. #3639 |
I already tried Avalonia, probably the best framework for desktop-only development, but not most scenarios. Still I'm developing a cross-platform application (Desktop, Mobile, Web), and I'm using the Uno Platform for this. On Windows, I rely on WinUI3. |
This is a basic feature that should work by default. We deserve an update on this. I encountered the same issue and it's just annoying to see it doesn't work as expected. |
@tomtom-m I've allowed myself to improve your solution as it doesn't take 2 aspects into consideration:
|
Correction, @bogdan-patraucean :
and the same for the other side... |
Do not exagerate... The library is very good. There are some minor problems only. |
That wasn't an exaggeration by any means. It is an example of pain point that has never been fixed (but should have been easy to resolve). It's why, among many other things, many companies (including mine) dropped UWP/WinUI. Even MAUI is adding a WPF backend because WinUI 3 future is in question. |
There are some really serious problems. Indeed, maybe this isn't one of them but they add up. You can't event set a Min or Max width and height for a Window. I myself have a lot of issues opened that haven't been fixed yet. The team working on this is small, and their effort is sometimes redirected in other parts than fixing the library, like File Explorer for example. |
A bit off-topic, but where did you get this information? |
I'm curious too, it is not the first time I read similar comment un WinUI team.
Moreover, you cannot either set the width/height of the Window, you have to get AppWindow to do it. Nothing near to an issue, but it seems I'm not using a "native" framework.
Exactly, there are many bugs also on TreeView (I have performed a query and there are 73 open issues, I have personally hit few of them), and this is a quite basic component, TreeView exists since WinForms and even before. Now, I'm not really blaming the developers, I know that if man-power and budget is not enough the result cannot be satisfying, but I would understand if investing in this framework will pay in the future. Currently I'm not giving up, just questioning :) UPDATE: even today, during daily activities, I have met 2 well known annoyances (or issues) about DialogContent (March 2019) and about NumberBox (August 2022). |
At this point let's just say rumors from the BUILD conference. |
Fix is in to not add spacing for collased items. It is scheduled for 1.5. |
@JJBrychell awesome news, I can finally ditch my custom Stackpanel. |
Applying fix analogous to microsoft/microsoft-ui-xaml#916
Applying fix analogous to microsoft/microsoft-ui-xaml#916
|
See #9491 for |
Describe the bug
StackPanel applies Spacing to Collapsed child items, which means a Collapsed item causes whitespace of 2x the spacing value.
Steps to reproduce the bug
Expected behavior
Collapsed elements should not be considered in Spacing calculations.
Screenshots
Version Info
C# UWP app targeting 1903 SDK
NuGet package version:
n/a
The text was updated successfully, but these errors were encountered: