summaryrefslogtreecommitdiff
path: root/docs/Xamarin.Forms.Core/Xamarin.Forms/ListViewCachingStrategy.xml
blob: f783b452a970148231bf060625b2f66883112e8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<Type Name="ListViewCachingStrategy" FullName="Xamarin.Forms.ListViewCachingStrategy">
  <TypeSignature Language="C#" Value="public enum ListViewCachingStrategy" />
  <TypeSignature Language="ILAsm" Value=".class public auto ansi sealed ListViewCachingStrategy extends System.Enum" />
  <AssemblyInfo>
    <AssemblyName>Xamarin.Forms.Core</AssemblyName>
    <AssemblyVersion>1.5.0.0</AssemblyVersion>
    <AssemblyVersion>2.0.0.0</AssemblyVersion>
  </AssemblyInfo>
  <Base>
    <BaseTypeName>System.Enum</BaseTypeName>
  </Base>
  <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:Xamarin.Forms.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:Xamarin.Forms.ListViewCachingStrategy.RetainElement" />. For performance reasons, it is likely that the default behavior will be changed to <see cref="F:Xamarin.Forms.ListViewCachingStrategy.RecycleElement" /> in a future release. In the meantime, for memory and performance reasons, app developers should specify <see cref="F:Xamarin.Forms.ListViewCachingStrategy.RecycleElement" /> when constructing a new List View.</para>
      <para>The performance advantage of <see cref="F:Xamarin.Forms.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:Xamarin.Forms.ListView.ListView(Xamarin.Forms.ListViewCachingStrategy)" /> constructor, XAML for Xamarin.Forms 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 devolopers specify <see cref="F:Xamarin.Forms.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:Xamarin.Forms.ListViewCachingStrategy.RecycleElement" /> in a future release. </block>
      </para>
    </remarks>
  </Docs>
  <Members>
    <Member MemberName="RecycleElement">
      <MemberSignature Language="C#" Value="RecycleElement" />
      <MemberSignature Language="ILAsm" Value=".field public static literal valuetype Xamarin.Forms.ListViewCachingStrategy RecycleElement = int32(1)" />
      <MemberType>Field</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>1.5.0.0</AssemblyVersion>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>Xamarin.Forms.ListViewCachingStrategy</ReturnType>
      </ReturnValue>
      <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="RetainElement">
      <MemberSignature Language="C#" Value="RetainElement" />
      <MemberSignature Language="ILAsm" Value=".field public static literal valuetype Xamarin.Forms.ListViewCachingStrategy RetainElement = int32(0)" />
      <MemberType>Field</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>1.5.0.0</AssemblyVersion>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>Xamarin.Forms.ListViewCachingStrategy</ReturnType>
      </ReturnValue>
      <Docs>
        <summary>Indicates that for every item in the List View's <see cref="P:Xamarin.Forms.ItemsView{TVisual}.ItemsSource" /> property, a single unique element will be constructed from the DataTemplate.</summary>
      </Docs>
    </Member>
  </Members>
</Type>