FrameworkElement.VerticalAlignment 属性

定义

获取或设置在父元素(如面板或项控件)中组合此元素时所应用的垂直对齐特征。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.

public:
 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.

VerticalAlignmentMicrosoft .NETMicrosoft .NET 属性访问器,对于实际上是依赖属性。VerticalAlignment 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. 例如,ComboBoxItem 控件的 VerticalAlignment 的外观 "默认" 将 Center,即使 ComboBoxItemVerticalAlignment 继承 FrameworkElement直接。For 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

适用于