次の方法で共有


TextAlignment 拡張機能

TextAlignment 拡張機能は、ITextAlignment を実装するコントロールのテキスト配置の構成をサポートする一連の拡張メソッドを提供します。

TextStart

TextStart メソッドは、ITextAlignment.HorizontalTextAlignment プロパティを TextAlignment.Start に設定します。

TextStart を使用して Label.HorizontalTextAlignmentTextAlignment.Start に設定の例を次に示します:

new Label().TextStart()

TextCenterHorizontal

TextCenterHorizontal メソッドは、ITextAlignment.HorizontalTextAlignment プロパティを TextAlignment.Center に設定します。

TextCenterHorizontal を使用して Label.HorizontalTextAlignmentTextAlignment.Center に設定の例を次に示します:

new Label().TextCenterHorizontal()

TextEnd

TextEnd メソッドは、ITextAlignment.HorizontalTextAlignment プロパティを TextAlignment.End に設定します。

TextEnd を使用して Label.HorizontalTextAlignmentTextAlignment.End に設定の例を次に示します:

new Label().TextEnd()

TextTop

TextTop メソッドは、ITextAlignment.VerticalTextAlignment プロパティを TextAlignment.Start に設定します。

TextTop を使用して Label.VerticalTextAlignmentTextAlignment.Start に設定の例を次に示します:

new Label().TextTop()

TextCenterVertical

TextCenterVertical メソッドは、ITextAlignment.VerticalTextAlignment プロパティを TextAlignment.Center に設定します。

TextCenterVertical を使用して Label.VerticalTextAlignmentTextAlignment.Center に設定の例を次に示します:

new Label().TextCenterVertical()

TextBottom

TextBottom メソッドは、ITextAlignment.VerticalTextAlignment プロパティを TextAlignment.End に設定します。

TextBottom を使用して Label.VerticalTextAlignmentTextAlignment.End に設定の例を次に示します:

new Label().TextBottom()

TextCenter

TextCenter メソッドは、ITextAlignment.HorizontalTextAlignment プロパティと ITextAlignment.VerticalTextAlignment プロパティの両方を TextAlignment.Center に設定します。

TextCenter を使用して Label.VerticalTextAlignmentLabel.HorizontalTextAlignmentの両方を TextAlignment.Center に設定する例を次に示します:

new Label().TextCenter()

LeftToRight

LeftToRight 名前空間には、TextLeftTextRightの 2 つの拡張メソッドが含まれており、これは左から右のスクリプトに合わせて配置されます。

LeftToRight 拡張機能を使用するには、まず次の using ディレクティブを追加する必要があります:

using CommunityToolkit.Maui.Markup.LeftToRight;

TextLeft

TextLeft メソッドは、 ITextAlignment.HorizontalTextAlignment プロパティを TextAlignment.Start に設定し、左から右のスクリプトに配置します。

TextLeft を使用して Label.HorizontalTextAlignmentTextAlignment.Start に設定の例を次に示します:

using CommunityToolkit.Maui.Markup.LeftToRight;

// ...

new Label().TextLeft()

TextRight

TextRight メソッドは、 ITextAlignment.HorizontalTextAlignment プロパティを TextAlignment.End に設定し、左から右のスクリプトに配置します。

TextRight を使用して Label.HorizontalTextAlignmentTextAlignment.End に設定の例を次に示します:

using CommunityToolkit.Maui.Markup.LeftToRight;

// ...

new Label().TextRight()

RightToLeft

RightToLeft 名前空間には、TextLeftTextRightの 2 つの拡張メソッドが含まれており、これは右から左のスクリプトに合わせて配置されます。

LeftToRight 拡張機能を使用するには、まず次の using ディレクティブを追加する必要があります:

using CommunityToolkit.Maui.Markup.RightToLeft;

TextLeft

TextLeft メソッドは、 ITextAlignment.HorizontalTextAlignment プロパティを TextAlignment.End に設定し、右から左のスクリプトに配置します。

TextLeft を使用して Label.HorizontalTextAlignmentTextAlignment.End に設定の例を次に示します:

using CommunityToolkit.Maui.Markup.RightToLeft;

// ...

new Label().TextLeft()

TextRight

TextRight メソッドは、 ITextAlignment.HorizontalTextAlignment プロパティを TextAlignment.Start に設定し、右から左のスクリプトに配置します。

TextRight を使用して Label.HorizontalTextAlignmentTextAlignment.Start に設定の例を次に示します:

using CommunityToolkit.Maui.Markup.RightToLeft;

// ...

new Label().TextRight()