ItemsView<TVisual>.ItemTemplate プロパティ

定義

ItemsSource に適用する DataTemplate を取得または設定します。

public Xamarin.Forms.DataTemplate ItemTemplate { get; set; }
member this.ItemTemplate : Xamarin.Forms.DataTemplate with get, set

プロパティ値

DataTemplate

の、 DataTemplate ItemsView<TVisual> またはnull

注釈

ItemTemplate は、からのオブジェクトの外観を定義するために使用され ItemsSource ます。 項目テンプレートを使用して、指定されたユーザーオブジェクトへのデータバインディングを設定して、ビジュアルに自動的に入力し、ユーザーオブジェクトの変更に応答することができます。

項目テンプレートがの場合は null 、ItemsView'1 (system.object) が呼び出され、結果がビジュアルとして使用されます。

この例では、 TextCell 単純なユーザーオブジェクトに対してのテンプレートが作成されます。

class Person
{
  public string FullName
  {
    get;
    set;
  }

  public string Address
  {
    get;
    set;
  }
}

void SetupView()
{
  var template = new DataTemplate (typeof (TextCell));

  // We can set data bindings to our supplied objects.
  template.SetBinding (TextCell.TextProperty, "FullName");
  template.SetBinding (TextCell.DetailProperty, "Address");

  // We can also set values that will apply to each item.
  template.SetValue (TextCell.TextColorProperty, Color.Red);

  itemsView.ItemTemplate = template;
  itemsView.ItemsSource = new[] {
    new Person { FullName = "James Smith", Address = "404 Nowhere Street" },
    new Person { FullName = "John Doe", Address = "404 Nowhere Ave" }
  };
}

適用対象

こちらもご覧ください