<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<controls:Page
    x:Class="MUXControlsTestApp.Samples.CollectionChangeDemo"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="http://schemas.modernwpf.com/2019"
    xmlns:utils="clr-namespace:MUXControlsTestApp.Utils"
    DataContext="{Binding RelativeSource={RelativeSource Self}}">

    <Page.Resources>
        <controls:RecyclePool x:Key="RecyclePool" />
        <controls:RecyclingElementFactory x:Key="elementFactory" RecyclePool="{StaticResource RecyclePool}">
            <controls:RecyclingElementFactory.Templates>
                <DataTemplate x:Key="Item">
                    <Button
                        Content="{Binding}"
                        Width="100"
                        Height="100"
                        Click="OnItemClicked" />
                </DataTemplate>
            </controls:RecyclingElementFactory.Templates>
        </controls:RecyclingElementFactory>
    </Page.Resources>

    <Grid Background="{DynamicResource SystemControlPageBackgroundAltHighBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Vertical">
            <StackPanel Orientation="Horizontal">
                <Button x:Name="goBackButton">Back</Button>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock>OldStartingIndex:</TextBlock>
                <TextBox
                    x:Name="oldStartIndex"
                    Text="0" />
                <TextBlock>OldCount:</TextBlock>
                <TextBox
                    x:Name="oldCount"
                    Text="0" />
                <TextBlock>NewStartingIndex:</TextBlock>
                <TextBox
                    x:Name="newStartIndex"
                    Text="0" />
                <TextBlock>NewCount:</TextBlock>
                <TextBox
                    x:Name="newCount"
                    Text="0" />
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <ToggleButton x:Name="resetMode">ResetMode</ToggleButton>
                <Button x:Name="insertButton">Insert</Button>
                <Button x:Name="removeButton">Remove</Button>
                <Button x:Name="replaceButton">Replace</Button>
                <Button x:Name="moveButton">Move</Button>
                <Button x:Name="resetButton">Reset</Button>
                <Button x:Name="invalidateMeasureButton">InvalidateMeasure</Button>
                <Button x:Name="invalidateArrangeButton">InvalidateArrange</Button>
            </StackPanel>
        </StackPanel>

        <controls:ItemsRepeaterScrollHost
            x:Name="tracker"
            Grid.Row="1">
            <ScrollViewer x:Name="scrollViewer">
                <controls:ItemsRepeater x:Name="repeater">
                    <controls:ItemsRepeater.Layout>
                        <controls:UniformGridLayout
                            MinColumnSpacing="10"
                            MinItemHeight="150"
                            MinItemWidth="150"
                            MinRowSpacing="10" />
                    </controls:ItemsRepeater.Layout>
                    <!--<controls:ItemsRepeater.Animator>
                        <utils:DefaultElementAnimator />
                    </controls:ItemsRepeater.Animator>-->
                </controls:ItemsRepeater>
            </ScrollViewer>
        </controls:ItemsRepeaterScrollHost>

        <controls:ItemsRepeater
            x:Name="ResettingCollectionRepeater"
            Grid.Row="2"
            ItemsSource="{Binding ResettingListItems, Mode=OneWay}">
            <controls:ItemsRepeater.ItemTemplate>
                <DataTemplate>
                    <Grid
                        Width="300"
                        HorizontalAlignment="Left">
                        <Button
                            Width="140"
                            Height="40"
                            HorizontalAlignment="Right"
                            AutomationProperties.Name="{Binding}"
                            Click="ResettingCollectionRemoveItemButton_ItemClick"
                            Content="{Binding}" />
                    </Grid>
                </DataTemplate>
            </controls:ItemsRepeater.ItemTemplate>
        </controls:ItemsRepeater>
    </Grid>
</controls:Page>
