<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<ui:Page
    x:Class="MUXControlsTestApp.Samples.BasicDemo"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ui="http://schemas.modernwpf.com/2019"
    xmlns:controls="clr-namespace:ModernWpf.Controls;assembly=ModernWpf.Controls">

    <Page.Resources>
        <controls:RecyclePool x:Key="RecyclePool" />
        <DataTemplate x:Key="odd">
            <Button
                Content="{Binding}"
                Foreground="Red"
                Width="100"
                Height="100" />
        </DataTemplate>
        <DataTemplate x:Key="even">
            <Button
                Content="{Binding}"
                Foreground="Green"
                Width="100"
                Height="100" />
        </DataTemplate>
        <controls:RecyclingElementFactory
            x:Key="elementFactory"
            RecyclePool="{StaticResource RecyclePool}"
            SelectTemplateKey="OnSelectTemplateKey">
            <controls:RecyclingElementFactory.Templates>
                <ui:StaticResource x:Key="odd" ResourceKey="odd" />
                <ui:StaticResource x:Key="even" ResourceKey="even" />
            </controls:RecyclingElementFactory.Templates>
        </controls:RecyclingElementFactory>
    </Page.Resources>

    <Grid Background="{DynamicResource SystemControlPageBackgroundAltHighBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <StackPanel>
            <Button x:Name="goBackButton">Back</Button>
            <Button Click="OnAddRecipeButton_Click" AutomationProperties.Name="InsertAtStartButton">Insert item at start</Button>
            <TextBlock x:Name="InsertAtStartChildCountLabel" AutomationProperties.Name="InsertAtStartChildCountLabel" Text="0"/>
        </StackPanel>

        <controls:ItemsRepeaterScrollHost
            x:Name="tracker"
            Grid.Row="1">
            <ScrollViewer x:Name="scrollViewer">
                <controls:ItemsRepeater
                    x:Name="repeater"
                    VerticalCacheLength="0"
                    Background="LightBlue">
                    <controls:ItemsRepeater.Layout>
                        <controls:StackLayout DisableVirtualization="True" />
                    </controls:ItemsRepeater.Layout>
                </controls:ItemsRepeater>
            </ScrollViewer>
        </controls:ItemsRepeaterScrollHost>

        <controls:ItemsRepeaterScrollHost Grid.Row="2">
            <ScrollViewer>
                <controls:ItemsRepeater Grid.Row="2" MinHeight="100"
                    x:Name="insertStartTestRepeater"
                    ItemsSource="{x:Bind simpleStringsList}">
                    <controls:ItemsRepeater.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="{Binding}" VerticalAlignment="Center"/>
                            </Grid>
                        </DataTemplate>
                    </controls:ItemsRepeater.ItemTemplate>
                </controls:ItemsRepeater>
            </ScrollViewer>
        </controls:ItemsRepeaterScrollHost>
    </Grid>
</ui:Page>
