Control.HorizontalContentAlignment プロパティ
定義
コントロールのコンテンツの水平方向の配置を取得または設定します。Gets or sets the horizontal alignment of the control's content.
public:
property System::Windows::HorizontalAlignment HorizontalContentAlignment { System::Windows::HorizontalAlignment get(); void set(System::Windows::HorizontalAlignment value); };
[System.ComponentModel.Bindable(true)]
public System.Windows.HorizontalAlignment HorizontalContentAlignment { get; set; }
member this.HorizontalContentAlignment : System.Windows.HorizontalAlignment with get, set
Public Property HorizontalContentAlignment As HorizontalAlignment
プロパティ値
HorizontalAlignment 値のいずれか 1 つ。One of the HorizontalAlignment values. 既定値は、Left です。The default is Left.
- 属性
例
次の例は、コントロールの横方向のコンテンツの配置プロパティを設定する方法を示しています。The following example shows how to set the horizontal content alignment property of a control.
<Button Name="btn7"
HorizontalContentAlignment="Left"
Click="ChangeHorizontalContentAlignment">
HorizontalContentAlignment
</Button>
void ChangeHorizontalContentAlignment(object sender, RoutedEventArgs e)
{
if (btn7.HorizontalContentAlignment == HorizontalAlignment.Left)
{
btn7.HorizontalContentAlignment = HorizontalAlignment.Right;
btn7.Content = "Control horizontal alignment changes from left to right.";
}
else
{
btn7.HorizontalContentAlignment = HorizontalAlignment.Left;
btn7.Content = "HorizontalContentAlignment";
}
}
Private Sub ChangeHorizontalContentAlignment(ByVal Sender As Object, ByVal e As RoutedEventArgs)
If (btn7.HorizontalContentAlignment = HorizontalAlignment.Left) Then
btn7.HorizontalContentAlignment = HorizontalAlignment.Right
btn7.Content = "Control horizontal alignment changes from left to right."
Else
btn7.HorizontalContentAlignment = HorizontalAlignment.Left
btn7.Content = "HorizontalContentAlignment"
End If
End Sub
注釈
Left、 Stretch、およびに加えHorizontalContentAlignmentて、プロパティをに設定することもできます。これにより、子要素が親要素の割り当てられた領域に合わせて拡大されます。 Center RightIn addition to Left, Right, and Center, you can set the HorizontalContentAlignment property to Stretch, which stretches the child element to fill the allocated space of the parent element. 詳細については、「配置、余白、パディングの概要」を参照してください。For more information, see Alignment, Margins, and Padding Overview.
このプロパティは、テンプレートがHorizontalContentAlignmentプロパティをパラメーターとして使用するコントロールにのみ影響します。This property only affects a control whose template uses the HorizontalContentAlignment property as a parameter. その他のコントロールでは、このプロパティは影響を与えません。On other controls, this property has no impact.
依存プロパティ情報Dependency Property Information
識別子フィールドIdentifier field | HorizontalContentAlignmentProperty |
メタデータプロパティがに設定されるtrue Metadata properties set to true |
NoneNone |