<Type Name="ListViewCachingStrategy" FullName="Microsoft.Maui.Controls.ListViewCachingStrategy">
  <TypeSignature Language="C#" Value="public enum ListViewCachingStrategy" />
  <TypeSignature Language="ILAsm" Value=".class public auto ansi sealed ListViewCachingStrategy extends System.Enum" />
  <TypeSignature Language="DocId" Value="T:Microsoft.Maui.Controls.ListViewCachingStrategy" />
  <TypeSignature Language="F#" Value="type ListViewCachingStrategy = " />
  <AssemblyInfo>
    <AssemblyName>Microsoft.Maui.Controls.Core</AssemblyName>
    <AssemblyVersion>0.0.0.0</AssemblyVersion>
    <AssemblyVersion>1.5.0.0</AssemblyVersion>
    <AssemblyVersion>2.0.0.0</AssemblyVersion>
  </AssemblyInfo>
  <Base>
    <BaseTypeName>System.Enum</BaseTypeName>
  </Base>
  <Attributes>
    <Attribute>
      <AttributeName>System.Flags</AttributeName>
    </Attribute>
  </Attributes>
  <Docs>
    <summary>Enumerates caching strategies for a ListView.</summary>
    <remarks>
      <para>Application developers can specify one of these values when constructing a <see cref="T:Microsoft.Maui.Controls.ListView" /> to determine whether the List View will minimize their memory footprint and speed execution by recycling list cells, or will instead generate a cell for every item in the list. Currently, the default behavior is to retain item data in their generated cells when they are not needed. (Items are not needed, for example, when they are far enough off screen that their display is not imminent.) This behavior corresponds to a value of <see cref="F:Microsoft.Maui.Controls.ListViewCachingStrategy.RetainElement" />. For performance reasons, it is likely that the default behavior will be changed to <see cref="F:Microsoft.Maui.Controls.ListViewCachingStrategy.RecycleElement" /> in a future release. In the meantime, for memory and performance reasons, app developers should specify <see cref="F:Microsoft.Maui.Controls.ListViewCachingStrategy.RecycleElement" /> when constructing a new List View.</para>
      <para>The performance advantage of <see cref="F:Microsoft.Maui.Controls.ListViewCachingStrategy.RecycleElement" /> is so great that application developers have been provided with a XAML syntax shortcut for initializing List Views. Instead of <c>x:TypeArguments</c> syntax that specifies a parameter for the <see cref="M:Microsoft.Maui.Controls.ListView.#ctor(Microsoft.Maui.Controls.ListViewCachingStrategy)" /> constructor, XAML for Microsoft.Maui.Controls provides a XAML attribute for a non-existent property that corresponds to the caching strategy argument of the constructor. Application developers can set the <c>CachingStrategy</c> attribute to either of the <c>RecycleElement</c> (preferred) or <c>RetainElement</c> values to choose a caching strategy. For example:</para>
      <code lang="XAML"><![CDATA[
<ListView CachingStrategy="RecycleElement" >
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <!-- ... -->
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>]]></code>
      <para>
        <block type="note">When developers specify <see cref="F:Microsoft.Maui.Controls.ListViewCachingStrategy.RecycleElement" />, <c>OnElementChanged</c> events are not raised when cells are recycled. Instead,  the cell is retained and its property values change when the binding context is updated to that of an available cell, <c>OnElementPropertyChanged</c> events are raised. Application developers should remember to listen for the correct events, and should note that their renderers will need to be updated if the default behavior changes to <see cref="F:Microsoft.Maui.Controls.ListViewCachingStrategy.RecycleElement" /> in a future release.</block>
      </para>
      <para>
        <block type="note">The UWP platform ignores <see cref="F:Microsoft.Maui.Controls.ListViewCachingStrategy.RetainElement" />, because it always uses caching to improve performance. Therefore, if the developer has opted not to use data bindings, they must use <see cref="M:Microsoft.Maui.Controls.ListView.OnBindingContextChanged" /> to update cell data on UWP, because it always behaves as if <see cref="F:Microsoft.Maui.Controls.ListViewCachingStrategy.RecycleElement" /> was specified.</block>
      </para>
    </remarks>
  </Docs>
  <Members>
    <Member MemberName="RecycleElement">
      <MemberSignature Language="C#" Value="RecycleElement" />
      <MemberSignature Language="ILAsm" Value=".field public static literal valuetype Microsoft.Maui.Controls.ListViewCachingStrategy RecycleElement = int32(1)" />
      <MemberSignature Language="DocId" Value="F:Microsoft.Maui.Controls.ListViewCachingStrategy.RecycleElement" />
      <MemberSignature Language="F#" Value="RecycleElement = 1" Usage="Microsoft.Maui.Controls.ListViewCachingStrategy.RecycleElement" />
      <MemberType>Field</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>0.0.0.0</AssemblyVersion>
        <AssemblyVersion>1.5.0.0</AssemblyVersion>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
        <AssemblyName>Microsoft.Maui.Controls.Core</AssemblyName>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>Microsoft.Maui.Controls.ListViewCachingStrategy</ReturnType>
      </ReturnValue>
      <MemberValue>1</MemberValue>
      <Docs>
        <summary>Indicates that unneeded cells will have their binding contexts updated to that of a cell that is needed.</summary>
      </Docs>
    </Member>
    <Member MemberName="RecycleElementAndDataTemplate">
      <MemberSignature Language="C#" Value="RecycleElementAndDataTemplate" />
      <MemberSignature Language="ILAsm" Value=".field public static literal valuetype Microsoft.Maui.Controls.ListViewCachingStrategy RecycleElementAndDataTemplate = int32(3)" />
      <MemberSignature Language="DocId" Value="F:Microsoft.Maui.Controls.ListViewCachingStrategy.RecycleElementAndDataTemplate" />
      <MemberSignature Language="F#" Value="RecycleElementAndDataTemplate = 3" Usage="Microsoft.Maui.Controls.ListViewCachingStrategy.RecycleElementAndDataTemplate" />
      <MemberType>Field</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.ListViewCachingStrategy</ReturnType>
      </ReturnValue>
      <MemberValue>3</MemberValue>
      <Docs>
        <summary>Indicates that, in addition to the behavior specified by <see cref="F:Microsoft.Maui.Controls.ListViewCachingStrategy.RecycleElement" />, <see cref="T:Microsoft.Maui.Controls.DataTemplate" /> objects that are selected by a <see cref="T:Microsoft.Maui.Controls.DataTemplateSelector" /> are cached by the data template type.</summary>
      </Docs>
    </Member>
    <Member MemberName="RetainElement">
      <MemberSignature Language="C#" Value="RetainElement" />
      <MemberSignature Language="ILAsm" Value=".field public static literal valuetype Microsoft.Maui.Controls.ListViewCachingStrategy RetainElement = int32(0)" />
      <MemberSignature Language="DocId" Value="F:Microsoft.Maui.Controls.ListViewCachingStrategy.RetainElement" />
      <MemberSignature Language="F#" Value="RetainElement = 0" Usage="Microsoft.Maui.Controls.ListViewCachingStrategy.RetainElement" />
      <MemberType>Field</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>0.0.0.0</AssemblyVersion>
        <AssemblyVersion>1.5.0.0</AssemblyVersion>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
        <AssemblyName>Microsoft.Maui.Controls.Core</AssemblyName>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>Microsoft.Maui.Controls.ListViewCachingStrategy</ReturnType>
      </ReturnValue>
      <MemberValue>0</MemberValue>
      <Docs>
        <summary>Indicates that for every item in the List View's <see cref="P:Microsoft.Maui.Controls.ItemsView`1.ItemsSource" /> property, a single unique element will be constructed from the DataTemplate.</summary>
      </Docs>
    </Member>
  </Members>
</Type>
