Edward Tanguay
Edward Tanguay

Reputation: 193312

Why does XAML Margin not follow CSS norm?

In CSS the margin order is: top right bottom left

In XAML the margin order is: left top right bottom

Is there a reason why the WPF team didn't align this to the CSS norm?

Upvotes: 23

Views: 2723

Answers (2)

Richard McGuire
Richard McGuire

Reputation: 11090

I imagine this is because margins in WinForms were declared as left, top, right, bottom. They likely thought it would be more likely to have WinForms developers move on to WPF rather than those from the web.

For reference you can check the constructor for the Padding structure on MSDN (the type used for the Margin property).

Upvotes: 30

17 of 26
17 of 26

Reputation: 27382

They're not aligning to CSS norms - they're aligning with the way that Microsoft has done UI APIs in the past. I can't speak for WinForms, but in MFC coordinates are specified in the order of LTRB.

Upvotes: 18

Related Questions