FrameworkElement.VerticalAlignment FrameworkElement.VerticalAlignment FrameworkElement.VerticalAlignment FrameworkElement.VerticalAlignment Property


获取或设置在父元素(如面板或项控件)中组合此元素时所应用的垂直对齐特征。Gets or sets the vertical alignment characteristics applied to this element when it is composed within a parent element such as a panel or items control.

 property System::Windows::VerticalAlignment VerticalAlignment { System::Windows::VerticalAlignment get(); void set(System::Windows::VerticalAlignment value); };
public System.Windows.VerticalAlignment VerticalAlignment { get; set; }
member this.VerticalAlignment : System.Windows.VerticalAlignment with get, set
Public Property VerticalAlignment As VerticalAlignment


垂直对齐设置。A vertical alignment setting. 默认值为 StretchThe default is Stretch.


HeightWidth元素上显式设置了和属性时, 这些度量将采用布局引用单元格, 并取消将此属性Stretch设置为的常规效果。When Height and Width properties are explicitly set on an element, these measurements take layout precedent and cancel the regular effects of setting this property to Stretch.

VerticalAlignment实际上是依赖属性的属性访问器。Microsoft .NETMicrosoft .NETVerticalAlignment is the Microsoft .NETMicrosoft .NET property accessor for what is in reality a dependency property. 在派生元素类 (特别是控件) 中, 此特定依赖项属性非常频繁地以不同的方式设置其外观 "默认" 值。This particular dependency property quite frequently has its apparent "default" value set differently in derived element classes, particularly controls. 这通常采用以下两种方式之一: 依赖属性重新注册到特定的派生类, 但使用不同的元数据设置其默认值;否则, 将应用默认样式来设置该依赖属性值的不同值。This generally occurs in one of two ways: the dependency property is re-registered to a particular derived class, but with different metadata for setting its defaults; or there is a default style being applied that sets that dependency property value differently. 例如VerticalAlignment , FrameworkElement VerticalAlignment ComboBoxItem控件的外观 "默认"为,即使从直接继承。Center ComboBoxItemFor example, the apparent "default" of VerticalAlignment for a ComboBoxItem control will be Center, even though ComboBoxItem inherits VerticalAlignment direct from FrameworkElement. 这是因为此值在样式的控件模板内的ComboBoxItem默认样式中重置。This is because that value was reset within the default style of ComboBoxItem, within the style's control template.

Canvas不在编写VerticalAlignment布局时使用, 因为Canvas是基于绝对定位。Canvas does not use VerticalAlignment when composing layout, because Canvas is based on absolute positioning.

当由ComboBoxItem或任何派生类继承时ComboBoxItem , 将Center此属性的默认值重定义为。When inherited by ComboBoxItem or any derived classes, ComboBoxItem redefines the default value of this property to be Center.

依赖项属性信息Dependency Property Information

标识符字段Identifier field VerticalAlignmentProperty
元数据属性设置为trueMetadata properties set to true AffectsArrange