Element 拡張機能
Element
拡張機能には、Element
のパディング、効果、フォント属性、動的リソース、テキスト、テキストの色の構成をサポートする、一連の拡張メソッドが用意されています。
Padding
Padding
メソッドでは、IPaddingElement
に Padding
プロパティを設定します。
次の例では、Padding
を new Thickness(5, 10)
に設定します。
new Button().Padding(5, 10);
次の例では、Padding
を new Thickness(10, 20, 30, 40)
に設定します。
new Button().Padding(new Thickness(10, 20, 30, 40));
new Button().Paddings(10, 20, 30, 40);
RemoveDynamicResources
RemoveDynamicResources
メソッドでは、指定された BindableObject
からすべての動的リソースを削除します。
次の例では、DynamicResource
を BackgroundColorProperty
と TextColorProperty
から削除します。
var button = new Button().DynamicResources(
(Button.BackgroundColorProperty, "ButtonBackgroundColor"),
(Button.TextColorProperty, "ButtonTextColor"));
button.RemoveDynamicResources(Button.BackgroundColorProperty, Button.TextColorProperty);
エフェクト
Effects
メソッドは、指定された Effect
を Element
に添付します。
次の例では、ShadowEffect
と TouchEffect
を Element
に添付します。
new Button().Effects(new ShadowEffect(), new TouchEffect());
フォント サイズ
FontSize
メソッドでは、IFontElement
要素に FontSize
プロパティを設定します。
次の例では、FontSize
を 12
に設定します。
new Button().FontSize(12);
太字
Bold
メソッドでは、IFontElement
要素に FontAttributes = FontAttributes.Bold
を設定します。
次の例では、ボタンのフォントを太字に設定します。
new Button().Bold()
Normal
Italic
メソッドでは、IFontElement
要素に FontAttributes = FontAttributes.Italic
を設定します。
次の例では、ボタンのフォントをイタリックに設定します。
new Button().Italic()
Font
Font
メソッドでは、IFontElement
要素に FontFamily
、FontSize
、FontAttributes
を設定します。
次の例では、ボタンのフォントをイタリックに設定します。
new Button().Font(family: "OpenSansRegular", size: 12.5, bold: true, italic: true);
TextColor
TextColor
メソッドでは、ITextStyle
要素に TextColor
プロパティを設定します。
次の例では、TextColor
を Colors.Green
に設定します。
new Button().TextColor(Colors.Green);
Text
Text
メソッドでは、IText
要素に Text
プロパティを設定します。
次の例では、Text
を "Tap Here"
に設定します。
new Button().Text("Tap Here");
次の例では、Text
を "Tap Here"
に設定し、TextColor
プロパティを Colors.Blue
に設定します。
new Button().Text("Tap Here", Colors.Blue);
.NET MAUI Community Toolkit
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示