Xamarin.Forms.ItemsView<TVisual>.ItemTemplate Property
Gets or sets the Xamarin.Forms.DataTemplate to apply to the ItemsView<TVisual>.ItemsSource.

Syntax

public DataTemplate ItemTemplate { get; set; }

See Also

DataTemplate
ItemsView<TVisual>.ItemsSource
ItemsView<TVisual>.CreateDefault

Value

The Xamarin.Forms.DataTemplate for the Xamarin.Forms.ItemsView, or null

Remarks

The ItemTemplate is used to define the visual appearance of objects from the ItemsView<TVisual>.ItemsSource. Through the item template you can set up data bindings to the user objects supplied to automatically fill in the visual and respond to any changes in the user object.

If the item template is null, ItemsView<TVisual>.CreateDefault is called and the result is used as the visual.

In this example, a template for a Xamarin.Forms.TextCell is created for a simple user object.

C# Example

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 = temeplate;
  itemsView.ItemsSource = new[] {
    new Person { FullName = "James Smith", Address = "404 Nowhere Street" },
    new Person { FullName = "John Doe", Address = "404 Nowhere Ave" }
  };
}
            

Requirements

Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions: 1.0.0.0, 1.1.0.0, 1.2.0.0, 1.3.0.0