Second ExpanderView PrimaryView height issue when First Status changes to Expanded iOS - CollectionView
See original GitHub issue<CollectionView
ItemsSource="{Binding Items}"
VerticalOptions="StartAndExpand"
ItemSizingStrategy="MeasureAllItems">
<CollectionView.ItemsLayout>
<LinearItemsLayout
Orientation="Vertical"
ItemSpacing="0" />
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<expander:ExpandableView StateChanged="ExpandableViewStatusChanged">
<expander:ExpandableView.PrimaryView>
<Grid
RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition
Height="Auto" />
<RowDefinition
Height="40" />
<RowDefinition
Height="Auto" />
</Grid.RowDefinitions>
<BoxView
HeightRequest="1"
BackgroundColor="Gray"
Grid.Row="0" />
<StackLayout
x:Name="sl"
Spacing="0"
Orientation="Horizontal"
Grid.Row="1">
<Label
Margin="20,0,0,0"
x:Name="plusMinus"
Text="+"
VerticalTextAlignment="Center" />
<Label
Text="{Binding Title}"
Margin="10,0,0,0"
TextColor="Green"
VerticalOptions="Center"
VerticalTextAlignment="Center"
HorizontalOptions="Start" />
</StackLayout>
<BoxView
HeightRequest="1"
BackgroundColor="Gray"
Grid.Row="2" />
</Grid>
</expander:ExpandableView.PrimaryView>
<expander:ExpandableView.SecondaryViewTemplate>
<DataTemplate>
<Label
Padding="30,10"
Text="{Binding Detail}"
VerticalOptions="Start"
VerticalTextAlignment="Center" />
</DataTemplate>
</expander:ExpandableView.SecondaryViewTemplate>
</expander:ExpandableView>
</DataTemplate>
private void ExpandableViewStatusChanged(object sender, StatusChangedEventArgs args)
{
if (sender is ExpandableView expander)
{
if (expander.PrimaryView is Grid grid)
{
if (grid.FindByName("sl") is StackLayout titleStackLayout)
{
if (titleStackLayout.Children[0] is Label icon && titleStackLayout.Children[1] is Label titleText)
{
if (args.Status == ExpandStatus.Expanding)
{
Device.BeginInvokeOnMainThread(() => {
titleStackLayout.BackgroundColor = Color.Green;
icon.Text = "-";
icon.TextColor = Color.White;
titleText.TextColor = Color.White;
});
}
else if (args.Status == ExpandStatus.Collapsing)
{
Device.BeginInvokeOnMainThread(() => {
titleStackLayout.BackgroundColor = Color.White;
icon.Text = "+";
icon.TextColor = Color.Green;
titleText.TextColor = Color.Green;
});
}
}
}
}
}
}
iOS ScreenShot
Only 1st item selected(look at Item2 height) - this is wrong
Other selections which look fine
None expanded
all 3 expanded
middle only expanded
last 2 expanded
last only expanded
Tried calling expander.ForceUpdateSize() and (expander.PrimaryView as Grid).ForceLayout() but dint work as expected.
Android
On android it is fine.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Setting cell height of CollectionView, doesn't really expand ...
The size is actually queried before the cell is created. You need a way to calculate the cell's height before the collectionView asks...
Read more >issue with collection view sizing | Apple Developer Forums
Noticed a bunch of my collection views in beta 3 are showing up too tall, but immediately shrink to size when I scroll....
Read more >iOS
Customize iOS View Preview Container view. The second view is View. Set Leading and Top to Participant Collection View Cell and change the...
Read more >Expanding Collection View Cells
So by setting the height to an estimated value of 50 points, I am allowing it to grow or shrink as defined by...
Read more >Digging deep into UICollectionView | by Kuang Lin - Medium
Set the data empty. Expand the collectionView with height > 0. This is causing crash because when you reloadData() under 0 height or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Why?
@AndreiMisiukevich Thanks!