How to set absolute position for an UIElement in UWP?
Asked Answered
S

2

8

I want to set position attribute of an UIElement to an absolute value of X and Y. How can I do this operation? And why absolute positioning in UWP is so hard?

Stites answered 1/2, 2016 at 10:53 Comment(4)
Put it in a Canvas, and set the Canvas.Left and Canvas.Top to the desired x and y values.Lithomarge
"why absolute positioning in UWP is so hard" - because UWP apps are mostly responsive. If you develop a responsive design, you hardly ever use absolute positions.Shiri
If the answer of @Lithomarge isn't appropriate, you can also set the Margin property of your elementCompressed
Omg, Thank you! >.< I am so tired of not having any control over where things go. It'd be really nice if you could opt out of the ResponsiveUI crap for specific projects. Why am I using UWP, then? Because the only working GUI that I can find for .NET Linux coding is UWP based. (UnoPlatform). But, guess what? Industrial clients could care less if it's responsive - they want the sizes to be set to specifics in every aspect of the program, so that it conforms to their UI standards. And, with the shift from Windows to Linux, I can't use WinForms anymore. So, this is a Gold Mine to me. Thank you!Hoofbeat
D
1

First of all, absolute position in UWP is so hard, because GUI child elements built relative to the parent element(Page, Grid and etc) You can see, that if you open documentation to UIElement and open Property ActualOffset, you can see, that:

Gets the position of this UIElement, relative to its parent, computed during the > arrange pass of the layout process.

But you can change the point relative to which the coordinates are calculated by class GeneralTransform. Example you can see in this ticket.

Daniels answered 20/7, 2022 at 11:17 Comment(0)
B
1

Maybe this will be helpfull Canvas.SetLeft && Canvas.SetTop

Bernadinebernadotte answered 27/7, 2022 at 7:35 Comment(1)
Note, this risks being perceived as a link-only answer and being flagged as not an answer. I think the mentioning of the features alone is more than link-only. But you might want to write a little more directly here.Chance

© 2022 - 2024 — McMap. All rights reserved.