Page 1 of 1

Desktop mode: HorizontalAlignment="Center" broken in browsers?

Posted: Sat Oct 15, 2016 8:19 am
by cnayan
Hi just downloaded the beta 10 version and created the default calculator sample app.

In browsers that I tried, Edge and Chrome, the default app is located in top-left corner, even though the default XAML code states that the canvas has to be aligned horizontally to center.

Code: Select all

<Canvas Height="415" Width="320" Background="#FF161616" HorizontalAlignment="Center">

So, I feel this is a bug: the "HorizontalAlignment" property is not being evaluated correctly.

Strangely, if I add this VerticalAlignment="Top" to canvas element, the canvas is now located perfectly at top center of the page, as expected.

Something about vertical alignment is forcing correct evaluation of horizontal. :D

Please check and comment.

Regards,
Cnayan

Re: Desktop mode: HorizontalAlignment="Center" broken in browsers?

Posted: Sat Oct 15, 2016 11:42 am
by JS-Support @Userware
Hi Cnayan,

Welcome to the forums.

In the Microsoft XAML standard, the horizontal and vertical alignments are ignored in a Canvas. Items in a Canvas can only be positioned based on their Left/Top position. You need to use a Grid instead.

What is not normal is that setting vertical alignment affects horizontal alignment. it shouldn't. We are going to investigate this point.

Thanks.
Regards,
JS-Support

Re: Desktop mode: HorizontalAlignment="Center" broken in browsers?

Posted: Sat Oct 15, 2016 7:29 pm
by cnayan
Hi team,

I'm afraid you have misunderstood the use of the property "HorizontalAlignment". You are confusing it with "HorizontalContentAlignment", probably.

When HorizontalAlignment="Center" is set to canvas, the canvas itself must align to center of the space, in its parent control. This property affects the control itself.

What you explained above is true for HorizontalContentAlignment="Center", where the child of the control must get centered. This property is set at parent for child.

And I understand that the canvas ignores the alignment of its children using HorizontalContentAlignment="Center", not the one I mentioned.

References:
https://msdn.microsoft.com/en-us/librar ... t(v=vs.110).aspx
https://msdn.microsoft.com/en-us/librar ... t(v=vs.110).aspx

So, there is a bug, clearly.

Its great to interact with you!

Regards,
cnayan

Re: Desktop mode: HorizontalAlignment="Center" broken in browsers?

Posted: Mon Oct 17, 2016 9:45 am
by JS-Support @Userware
Oh, sorry, you are right. I thought you were referring to the alignment of the children of the Canvas. My mistake.

We are going to investigate this bug. I'll keep you updated asap.

Thanks a lot.
Regards,
JS-Support