wpf elements with a vertical alignment of top aren't exactly at the top and have a weird gap.
Hello, I have a window with the button at the top and I noticed that they aren't sticking to the top and have a weird gap in between the top and them, I believe it's most likely related to the grid but I can't find out why.
78 Replies
I'll make a quick github gist of the code rq
I'm fairly new to wpf, sorry if this some really easy thing to change
you can use the viual live tree to see what is causing the gap at top
thats what the toolbar at the top is for
could you explian me how exactly ?
I mean I can see the different controlers and stuff but it doesn't show much
also I found out that there is not only a gap but something that puts itself on top of everything making it so that margins don't work
It may be the quick action bar causing just a visual. Try disabling it in the tools XAML Designer section
Please do not use the designer
$rulesofwpf
Margin is the spacing between elements, it is not absolute position
Please use the layout controls, such as Grid, DockPanel, StackPanel, etc.
buh I really just choose wpf because it had that designer + code change and no weird docks and grid stuff
Use hot reload
well thanks for the heads up
designer + code changeThis is exactly what WPF is not You're describing WinForms
ow okay
You should never use designer in XAML frameworks as they are horrible
sorry for my lack of knowledge
WinForms is ancient and should not be used, but it does have a drag n drop style.
However .. It still will fail if you resize the application
WinForms also barely supports transparency
ah
well still I'm close to finishing that project I want to finish it before moving to avalonia or something else
Avalonia is XAML as well .. Soo
And it does not have a designer at all. It does have a previewer but that is just to interact with the app. Not drag 'n drop elements / design with
guh
WYSIWYG editors are not of this millennia, they all suck
what would you recommend then
Well .. XAML?
And to use hot reload
just run your app and edit the XAML, you'll see the changes get reflected live while running the app
mmmokay
and obviously to use the layout controls
And disable that quick actions bar
yeah I'll try that thanks
and they exists in pretty much any UI framework
Imagine if your monitor's center point is 500px, but what if I have a bigger screen and my center point is 1000px?
Your center is not always other users center point.
That's basically what the issue of using absolute positions (and without layout controls)
sooo much hate here for the wpf designer..xD
it isnt thaaat bad
also hot reload also doesnt work always
Yes, it does work always.
It might not if you use bad UI Frameworks like WInUI3 or .NET MAUI
Try to resize an app that is made with purely the designer.
easy
you can do most stuff that you do in code in the propertywindow
its a pain in the ass but it works
its a pain in the assExactly. If you just learn XAML, making an app with the designer will be x3 slower And of course use hot reload as well Things such as window themes aren't reflected in the designer either
i still stand on the opinion that hotreload isnt THE solution
-designer supports designtime data, to show dummydata in running application you have often more work
-some changes cant be hotreloaded
-you need a test environment
you can do it
at least we do it with devexpress
Avalonia did good by not having a WYSIWYG editor. It is purely to interact with the app when a hot reload did not exist at the time, but it does exist now via a 3rd party library.
devexpress .. That is paid?
jea
You'd rather pay for something to see the theme in a designer than to use hot reload? Seems wasteful
naa we have more uses just saying that we are using themes created with devexpress which we can also see in designer
With hot reload you can also change the code at runtime as well as the XAML
just slam d:Theme=... in window root and designer will use that theme
not all changes are hot reloadable
Sure, but rather that than have to rely on a designer that is broken and completely wrong and no live code change at all.
If you want a decent WYSIWYG editor, check Uno. But I heard that is also quite bad.
im not saying that there is no use for hot reload..
i use both at the same time..
i do the groundwork in the designer and then adjust stuff via hotreload..
and again... the designer for previewing things, doing touchups and so on isnt thaaat bad
not to be mean or anything but can you two go in another channel ?
kinda went off topic
It still is on topic, but yes. I won't argue further.
Either way, I apologize.
What buttons were misaligned?
no worries thanks for you input
In the code that is
it's not an alignment issue but just two buttons aren't really at the top
can't explain it very well sorry
I'm trying to figure out what that is though
you went do hard on rant that you didnt even notice that
btn_OtherData
Btn_OpenSettings
dont even have margins
What names do they have?
the ones AciDCA7 just sent
Other things do which may screw up alignment / positioning
you can see in the designer both buttons are at the top as well
that is most likely your windowchrome
what's that ?
you tried to hide the windowtitlebar/border.. but you didnt hide everything
the piece at the top is still a bit left of the windowcontainerstuff
I tried the exact same code, it is at the top for me.
ah I see
what OS are you running
You mean version? WPF only supports one 😛
windows 10
stop being a dick..xD
huh
<-- Windows 11 user here
maybe windows 10 has that issue but not windows 10 ?
Do you have a spacing on other apps too or just this one?
well it's my only wpf app but I guess I can make another project rq to see
same when I tested the gist as well. windows10
i guess you guys were using net >5
golem are you using net framework or net >5
anyway... golem add this as window child
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="0" ResizeBorderThickness="5" />
</WindowChrome.WindowChrome>
sorry for the long delay but yeah I do
uhh how do I check that ?
was about to ask lol ty
ayy that fixed it thanks you !!!
and thanks you too everyone else for the help!
nonono i want to have all the thanks for myself
lolll
Now who being aaaaaaa!
https://discord.com/channels/143867839282020352/1319031579309379757/1319045697114472448
ACiDCA7
stop being a dick..xD
Quoted by
<@605158607939436574> from #wpf elements with a vertical alignment of top aren't exactly at the top and have a weird gap. (click here)
React with ❌ to remove this embed.
Uno Hot Design is actually pretty damn slick. Uno made designers great again. It embeds the designer into the running application in debug mode and you toggle it with the debug toolbar. Your changes are to the actual live application. The XAML designer revolution is coming, albeit for WinUI / Uno 😄
It's like designer and hot reload in one
But I agree with the general sentiment. I was also on the "hot reload only" XAML wagon until a couple weeks ago.