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.

VerticalAlignment 是相依性屬性實際的 Microsoft .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,即使 ComboBoxItem 繼承 VerticalAlignment 直接來自 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 重新定義此屬性的預設值為 CenterWhen inherited by ComboBoxItem or any derived classes, ComboBoxItem redefines the default value of this property to be Center.

相依性屬性資訊Dependency Property Information

識別碼欄位Identifier field VerticalAlignmentProperty
設定為 true 的中繼資料屬性Metadata properties set to true AffectsArrange

適用於