BindableLayout 拡張機能
BindableLayout
拡張機能は、その EmptyView
、ItemSource
、ItemTemplate
の構成をサポートする一連の拡張メソッドを提供します。
EmptyView
EmptyView
メソッドでは、ILayout
に EmptyView
プロパティを設定します。
次の例では、EmptyView
を new Label().Text("No Items Found")
に設定します。
new VerticalStackLayout().EmptyView(new Label().Text("No Items Found"));
EmptyViewTemplate
EmptyViewTemplate
メソッドでは、ILayout
に EmptyViewTemplate
プロパティを設定します。
次の例では、EmptyViewTemplate
を new DataTemplate(() => new Label().Text("No Items Found"))
に設定します。
new VerticalStackLayout().EmptyViewTemplate(new DataTemplate(() => new Label().Text("No Items Found")));
EmptyViewTemplate
にはオーバーロード メソッドがあり、DataTemplate
の初期化に使われる Func<object>
を受け入れます。
new VerticalStackLayout().EmptyViewTemplate(() => new Label().Text("No Items Found"));
ItemsSource
ItemsSource
メソッドでは、ILayout
に ItemsSource
プロパティを設定します。
次の例では、ItemsSource
を new List<string> { "Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet" }
に設定します。
new VerticalStackLayout().ItemsSource(new List<string> { "Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet" });
ItemTemplate
ItemTemplate
メソッドでは、ILayout
に ItemTemplate
プロパティを設定します。
次の例では、ItemTemplate
を new DataTemplate(() => new Label().Bind(Label.TextProperty, ".")
に設定します。
new VerticalStackLayout().ItemTemplate(new DataTemplate(() => new Label().Bind(Label.TextProperty, Binding.SelfPath)));
ItemTemplate
にはオーバーロード メソッドがあり、DataTemplate
の初期化に使われる Func<object>
を受け入れます。
new VerticalStackLayout().ItemTemplate(() => new Label().Bind(Label.TextProperty, Binding.SelfPath));
ItemTemplateSelector
ItemTemplateSelector
メソッドでは、ILayout
に ItemTemplateSelector
プロパティを設定します。
次の例では、ItemTemplateSelector
を new CustomDataTemplateSelector()
に設定します。
new VerticalStackLayout().ItemTemplateSelector(new CustomDataTemplateSelector())
class CustomDataTemplateSelector : DataTemplateSelector
{
// ...
}
.NET MAUI Community Toolkit
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示