XamarinCommunityToolkit icon indicating copy to clipboard operation
XamarinCommunityToolkit copied to clipboard

[Bug] Expander shrinking in open position.

Open the-gozo opened this issue 2 years ago • 0 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. https://github.com/xamarin/XamarinCommunityToolkit/issues/420#issuecomment-641617903

Reproduction imagery

Sorry for the flickering. Expander.webm

the-gozo avatar Jan 27 '23 11:01 the-gozo