FrameworkElement.HorizontalAlignment FrameworkElement.HorizontalAlignment FrameworkElement.HorizontalAlignment FrameworkElement.HorizontalAlignment Property

定義

取得或設定套用至此元素在父項元素 (例如面板或項目控制項) 中組成時的水平對齊特性。Gets or sets the horizontal 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::HorizontalAlignment HorizontalAlignment { System::Windows::HorizontalAlignment get(); void set(System::Windows::HorizontalAlignment value); };
public System.Windows.HorizontalAlignment HorizontalAlignment { get; set; }
member this.HorizontalAlignment : System.Windows.HorizontalAlignment with get, set
Public Property HorizontalAlignment As HorizontalAlignment

屬性值

此水平對齊方式設定作為列舉值。A horizontal alignment setting, as a value of the enumeration. 預設為 StretchThe default is Stretch.

備註

HeightWidth項目上明確設定屬性,這些測量結果在配置期間會較高優先,並將取消設定的一般效果HorizontalAlignmentStretchWhen Height and Width properties are explicitly set on an element, these measurements take higher precedent during layout and will cancel the typical effects of setting HorizontalAlignment to Stretch.

HorizontalAlignmentMicrosoft .NETMicrosoft .NET屬性存取子是相依性屬性。HorizontalAlignment 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 subclassed elements, particularly controls. 這通常發生於兩種方式之一: 相依性屬性重新加以註冊特定的子類別,但具有不同的中繼資料,設定其預設值;或以不同的方式設定該相依性屬性值的預設樣式套用。This generally occurs in one of two ways: the dependency property is re-registered to a particular subclass, but with different metadata for setting its defaults; or there is a default style being applied that sets that dependency property value differently. 比方說,明顯 「 預設 」 的HorizontalAlignmentforLabel控制項將會是Left,即使Label繼承HorizontalAlignment直接從FrameworkElementFor example, the apparent "default" of HorizontalAlignment for a Label control will be Left, even though Label inherits HorizontalAlignment direct from FrameworkElement. 這是因為該值重設的預設樣式內Label,樣式的控制項範本內。This is because that value was reset within the default style of Label, within the style's control template.

Canvas 不會使用HorizontalAlignment當您在撰寫版面配置,因為Canvas根據絕對位置。Canvas does not use HorizontalAlignment when composing layout, because Canvas is based on absolute positioning.

當繼承Label或衍生類別,Label重新定義此相依性屬性的預設值LeftWhen inherited by Label or derived classes, Label redefines the default value of this dependency property to be Left.

相依性屬性資訊Dependency Property Information

識別項欄位Identifier field HorizontalAlignmentProperty
若要設定的中繼資料屬性 trueMetadata properties set to true AffectsArrange

適用於