<Type Name="DataTemplateSelector" FullName="Microsoft.Maui.Controls.DataTemplateSelector">
  <TypeSignature Language="C#" Value="public abstract class DataTemplateSelector : Microsoft.Maui.Controls.DataTemplate" />
  <TypeSignature Language="ILAsm" Value=".class public auto ansi abstract beforefieldinit DataTemplateSelector extends Microsoft.Maui.Controls.DataTemplate" />
  <TypeSignature Language="DocId" Value="T:Microsoft.Maui.Controls.DataTemplateSelector" />
  <TypeSignature Language="F#" Value="type DataTemplateSelector = class&#xA;    inherit DataTemplate" />
  <AssemblyInfo>
    <AssemblyName>Microsoft.Maui.Controls.Core</AssemblyName>
    <AssemblyVersion>0.0.0.0</AssemblyVersion>
    <AssemblyVersion>2.0.0.0</AssemblyVersion>
  </AssemblyInfo>
  <Base>
    <BaseTypeName>Microsoft.Maui.Controls.DataTemplate</BaseTypeName>
  </Base>
  <Interfaces />
  <Docs>
    <summary>Selects <see cref="T:Microsoft.Maui.Controls.DataTemplate" /> objects by data type and container.</summary>
    <remarks>
      <para>Application developers override the <see cref="M:Microsoft.Maui.Controls.DataTemplateSelector.OnSelectTemplate(System.Object,Microsoft.Maui.Controls.BindableObject)" /> method to return a unique <see cref="T:Microsoft.Maui.Controls.DataTemplate" /> for a data type and parent container combination. Additionally, because the same exact template instance must be returned for a given piece of data across successive calls to <see cref="M:Microsoft.Maui.Controls.DataTemplateSelector.SelectTemplate(System.Object,Microsoft.Maui.Controls.BindableObject)" />, developers should create and store these <see cref="T:Microsoft.Maui.Controls.DataTemplate" /> in their constructor overrides.</para>
      <block subset="none" type="note">Developers should note the following items:        <list type="bullet"><item><term>OnSelectTemplate must not return another DataTemplateSelector, and
        </term></item><item><term>The Android platform is limited to 20 templates per list view.</term></item></list></block>
      <example>The following example shows a basic use:
<code lang="c#"><![CDATA[class MyDataTemplateSelector : DataTemplateSelector
{
    public MyDataTemplateSelector ()
    {
        // Retain instances
        this.templateOne = new DataTemplate (typeof (ViewA));
        this.templateTwo = new DataTemplate (typeof (ViewB));
    }
    
    protected override DataTemplate OnSelectTemplate (object item, BindableObject container)
    {
        if (item is double)
            return this.templateOne;
        return this.templateTwo;
    }
    
    private readonly DataTemplate templateOne;
    private readonly DataTemplate templateTwo;
}]]></code></example>
    </remarks>
  </Docs>
  <Members>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="protected DataTemplateSelector ();" />
      <MemberSignature Language="ILAsm" Value=".method familyhidebysig specialname rtspecialname instance void .ctor() cil managed" />
      <MemberSignature Language="DocId" Value="M:Microsoft.Maui.Controls.DataTemplateSelector.#ctor" />
      <MemberType>Constructor</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>0.0.0.0</AssemblyVersion>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
        <AssemblyName>Microsoft.Maui.Controls.Core</AssemblyName>
      </AssemblyInfo>
      <Parameters />
      <Docs>
        <summary>Creates a new <see cref="T:Microsoft.Maui.Controls.DataTemplateSelector" /> with default values.</summary>
        <remarks>Application developers should provide their own constructors to create and store the <see cref="T:Microsoft.Maui.Controls.DataTemplate" /> objects that can be returned by this <see cref="T:Microsoft.Maui.Controls.DataTemplateSelector" />.</remarks>
      </Docs>
    </Member>
    <Member MemberName="OnSelectTemplate">
      <MemberSignature Language="C#" Value="protected abstract Microsoft.Maui.Controls.DataTemplate OnSelectTemplate (object item, Microsoft.Maui.Controls.BindableObject container);" />
      <MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance class Microsoft.Maui.Controls.DataTemplate OnSelectTemplate(object item, class Microsoft.Maui.Controls.BindableObject container) cil managed" />
      <MemberSignature Language="DocId" Value="M:Microsoft.Maui.Controls.DataTemplateSelector.OnSelectTemplate(System.Object,Microsoft.Maui.Controls.BindableObject)" />
      <MemberSignature Language="F#" Value="abstract member OnSelectTemplate : obj * Microsoft.Maui.Controls.BindableObject -&gt; Microsoft.Maui.Controls.DataTemplate" Usage="dataTemplateSelector.OnSelectTemplate (item, container)" />
      <MemberType>Method</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>0.0.0.0</AssemblyVersion>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
        <AssemblyName>Microsoft.Maui.Controls.Core</AssemblyName>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>Microsoft.Maui.Controls.DataTemplate</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="item" Type="System.Object" />
        <Parameter Name="container" Type="Microsoft.Maui.Controls.BindableObject" />
      </Parameters>
      <Docs>
        <param name="item">The data for which to return a template.</param>
        <param name="container">An optional container object in which the developer may have opted to store <see cref="T:Microsoft.Maui.Controls.DataTemplateSelector" /> objects.</param>
        <summary>The developer overrides this method to return a valid data template for the specified <paramref name="item" />. This method is called by <see cref="M:Microsoft.Maui.Controls.DataTemplateSelector.SelectTemplate(System.Object,Microsoft.Maui.Controls.BindableObject)" />.</summary>
        <returns>A developer-defined <see cref="T:Microsoft.Maui.Controls.DataTemplate" /> that can be used to display <paramref name="item" />.</returns>
        <remarks>
          <para>This method causes <see cref="M:Microsoft.Maui.Controls.DataTemplateSelector.SelectTemplate(System.Object,Microsoft.Maui.Controls.BindableObject)" /> to throw an exception if it returns an instance of <see cref="T:Microsoft.Maui.Controls.DataTemplateSelector" />.</para>
        </remarks>
      </Docs>
    </Member>
    <Member MemberName="SelectTemplate">
      <MemberSignature Language="C#" Value="public Microsoft.Maui.Controls.DataTemplate SelectTemplate (object item, Microsoft.Maui.Controls.BindableObject container);" />
      <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Microsoft.Maui.Controls.DataTemplate SelectTemplate(object item, class Microsoft.Maui.Controls.BindableObject container) cil managed" />
      <MemberSignature Language="DocId" Value="M:Microsoft.Maui.Controls.DataTemplateSelector.SelectTemplate(System.Object,Microsoft.Maui.Controls.BindableObject)" />
      <MemberSignature Language="F#" Value="member this.SelectTemplate : obj * Microsoft.Maui.Controls.BindableObject -&gt; Microsoft.Maui.Controls.DataTemplate" Usage="dataTemplateSelector.SelectTemplate (item, container)" />
      <MemberType>Method</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>0.0.0.0</AssemblyVersion>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
        <AssemblyName>Microsoft.Maui.Controls.Core</AssemblyName>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>Microsoft.Maui.Controls.DataTemplate</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="item" Type="System.Object" />
        <Parameter Name="container" Type="Microsoft.Maui.Controls.BindableObject" />
      </Parameters>
      <Docs>
        <param name="item">The data for which to return a template.</param>
        <param name="container">An optional container object in which the developer may have opted to store <see cref="T:Microsoft.Maui.Controls.DataTemplateSelector" /> objects.</param>
        <summary>Returns a <see cref="T:Microsoft.Maui.Controls.DataTemplate" /> for <paramref name="item" /> by calling <see cref="M:Microsoft.Maui.Controls.DataTemplateSelector.OnSelectTemplate(System.Object,Microsoft.Maui.Controls.BindableObject)" /> and verifying its result.</summary>
        <returns>
          <para>A developer-defined <see cref="T:Microsoft.Maui.Controls.DataTemplate" /> that can be used to display <paramref name="item" />.</para>
        </returns>
        <remarks>
          <block subset="none" type="note">
            <para>Developers should note that the Android platform is limited to 20 templates per list view.</para>
          </block>
        </remarks>
      </Docs>
    </Member>
  </Members>
</Type>
