ItemsView<TVisual>.ItemTemplate プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
ItemsSource に適用する DataTemplate を取得または設定します。
public Xamarin.Forms.DataTemplate ItemTemplate { get; set; }
member this.ItemTemplate : Xamarin.Forms.DataTemplate with get, set
プロパティ値
、 DataTemplate または の ItemsView<TVisual>。 null
注釈
ItemTemplate は、 からオブジェクトの外観を定義するために使用されます ItemsSource。 アイテム テンプレートを使用すると、指定されたユーザー オブジェクトへのデータ バインディングを設定して、ビジュアルを自動的に入力し、ユーザー オブジェクトの変更に応答することができます。
項目テンプレートが の場合、 null
Xamarin.Forms.ItemsView'1.CreateDefault(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" }
};
}