xamarin / XamarinCommunityToolkit

The Xamarin Community Toolkit is a collection of Animations, Behaviors, Converters, and Effects for mobile development with Xamarin.Forms. It simplifies and demonstrates common developer tasks building iOS, Android, and UWP apps with Xamarin.Forms.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Expander shrinking in open position.

the-gozo opened this issue · comments

Description

Im aware that its not recommended to use Expander in ListView or CollectionView, but this is the other way around.

If I put a CollectionView inside Expander's DataTemplate, and also put a second CollectionView right under the Expander and start hitting the Expanders header, by every click it expands less then previously.

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="ExpanderTest.MainPage"
             xmlns:xct="http://xamarin.com/schemas/2020/toolkit" >

    <StackLayout>
        <xct:Expander>
            <xct:Expander.Header>
                <Label Text="Keep clickin'"/>
            </xct:Expander.Header>
            <xct:Expander.ContentTemplate>
                <DataTemplate>
                    <CollectionView ItemsSource="{Binding Strings}">
                        <CollectionView.ItemTemplate>
                            <DataTemplate>
                                <Label Text="{Binding .}" />
                            </DataTemplate>
                        </CollectionView.ItemTemplate>
                    </CollectionView>
                </DataTemplate>
            </xct:Expander.ContentTemplate>
        </xct:Expander>
        
        <CollectionView ItemsSource="{Binding Strings}" BackgroundColor="LightBlue">
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <Label Text="{Binding .}"/>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>
    </StackLayout>

</ContentPage>

Stack Trace

N/A

Link to Reproduction Sample

https://github.com/the-gozo/ExpanderTest

Steps to Reproduce

  1. Create Expander with CollectionView inside using Expanders DataTemplate.
  2. Put a second CollectionView under Expander.
  3. Set bot CollectionView's ItemsSource.
  4. Open and close expander several times.

Expected Behavior

Expander opened state height shoud be constant if there is no change in CollectionView ItemsSource.

Actual Behavior

It keeps shrinking (logarithmically I think.)

Basic Information

  • Version with issue:
    • Xamarin.CommunityToolkit 2.0.5
  • Last known good version:
    • no info
  • IDE:
    • VS 2022 17.4.3
  • Platform Target Frameworks:
    • Android: API level 29 & 30 tested on Emulator
    • IOS, UWP not tested
  • Nuget Packages:
    -- Xamarin.CommunityToolkit 2.0.5
  • Affected Devices:
    • Only tested on Android Emulator.

Workaround

Using ForceUpdateSizeCommand on Expander.
#420 (comment)

Reproduction imagery

Sorry for the flickering.
Expander.webm