.net 保证金中的属性顺序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8522018/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 16:07:02  来源:igfitidea点击:

Properties order in Margin

.netwpfxaml

提问by Papa John

If I have such string in XAML:

如果我在 XAML 中有这样的字符串:

Storyboard.TargetProperty="Margin" From="1,2,3,4" To="0,0,0,0"

What is Top Bottom Right and Left? 1- right 2- top 3- left 4 - bottom

什么是上右下左?1- 右侧 2- 顶部 3- 左侧 4 - 底部

Is that right?

那正确吗?

回答by Erno

Margin="1,2,3,4"
  1. Left,
  2. Top,
  3. Right,
  4. Bottom
  1. 剩下,
  2. 最佳,
  3. 对,
  4. 底部

It is also possible to specify just two sizes like this:

也可以只指定两种尺寸,如下所示:

Margin="1,2"
  1. Left AND right
  2. Top AND bottom
  1. 左和右
  2. 顶部和底部

Finally you can specify a single size:

最后,您可以指定单个尺寸:

Margin="1"
  1. used for all sides
  1. 用于所有方面

The order is the same as in WinForms.

顺序与 WinForms 中的相同。

回答by Contango

There are three unique situations:

有以下三种特殊情况:

  • 4 numbers, e.g. Margin="a,b,c,d".
  • 2 numbers, e.g. Margin="a,b".
  • 1 number, e.g. Margin="a".
  • 4 个数字,例如Margin="a,b,c,d"
  • 2个数字,例如Margin="a,b"
  • 1个数字,例如Margin="a"

4 Numbers

4个数字

If there are 4 numbers, then its left, top, right, bottom(a clockwise circle starting from the middle left margin). First number is always the "West" like "WPF":

如果有4 个数字,则其为left, top, right, bottom(从中间左边距开始的顺时针圆圈)。第一个数字总是像“WPF”一样的“西方”:

<object Margin="left,top,right,bottom"/>

Example: if we use Margin="10,20,30,40"it generates:

示例:如果我们使用Margin="10,20,30,40"它会生成:

enter image description here

在此处输入图片说明

2 Numbers

2 数字

If there are 2 numbers, then the first is left & right margin thickness, the second is top & bottom margin thickness. First number is always the "West" like "WPF":

如果有2 个数字,则第一个是左右边距厚度,第二个是顶部和底部边距厚度。第一个数字总是像“WPF”一样的“西方”:

<object Margin="a,b"/> // Equivalent to Margin="a,b,a,b".

Example: if we use Margin="10,30", the left & right margin are both 10, and the top & bottom are both 30.

示例:如果使用Margin="10,30",则左右边距均为 10,上下边距均为 30。

enter image description here

在此处输入图片说明

1 Number

1 个

If there is 1 number, then the number is repeated (its essentially a border thickness).

如果有1 个 number,则重复该数字(其本质上是边框厚度)。

<object Margin="a"/> // Equivalent to Margin="a,a,a,a".

Example: if we use Margin="20"it generates:

示例:如果我们使用Margin="20"它会生成:

enter image description here

在此处输入图片说明

Update 2020-05-27

更新 2020-05-27

Have been working on a large-scale WPF application for the past 5 years with over 100 screens. Part of a team of 5 WPF/C#/Java devs. We eventually settled on either using 1 number (for border thickness) or 4 numbers. We never use 2. It is consistent, and seems to be a good way to reduce cognitive load when developing.

在过去的 5 年里一直致力于开发一个拥有 100 多个屏幕的大型 WPF 应用程序。由 5 个 WPF/C#/Java 开发人员组成的团队的一部分。我们最终决定使用 1 个数字(用于边框厚度)或 4 个数字。我们从不使用 2。它是一致的,并且似乎是在开发时减少认知负荷的好方法。



The rule:

规则:

All width numbers start on the left (the "West" like "WPF") and go clockwise (if two numbers, only go clockwise twice, then mirror the rest).

所有宽度数字从左侧开始(“WPF”之类的“West”)并顺时针旋转(如果有两个数字,则只顺时针旋转两次,然后镜像其余部分)。

回答by Askolein

Just because @MartinCapodici 's comment is awesome I write here as an answer to give visibility.

仅仅因为@MartinCapodici 的评论很棒,所以我写在这里是为了提供可见性。

All clockwise:

全部顺时针:

  • WPF start West(left->top->right->bottom)
  • Netscape (ie CSS) start North(top->right->bottom->left)
  • WPF start West(left->top->right->bottom)
  • Ñetscape(即CSS)开始ÑORTH(顶>右>自下而上>左)

回答by chopikadze

<object Margin="left,top,right,bottom"/>
- or - 
<object Margin="left,top"/>
- or - 
<object Margin="thicknessReference"/>

See here: http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.margin.aspx

请参阅此处:http: //msdn.microsoft.com/en-us/library/system.windows.frameworkelement.margin.aspx