How to show uneven height children
nmano2188 opened this issue · comments
Mano Nagarajan commented
In content layout i have different types of control. How this will work on header click?
Update: By doing below changes i have implemented this.
Remove HeightRequest property from __content.
public AccordionSectionView(DataTemplate itemTemplate, ScrollView parent)
{
//_template = itemTemplate;
_headerTitle.BackgroundColor = _headerColor;
_headerIcon.Source = _arrowRight;
_header.BackgroundColor = _headerColor;
_header.Children.Add(_headerIcon, new Rectangle(0, 1, .1, 1), AbsoluteLayoutFlags.All);
_header.Children.Add(_headerTitle, new Rectangle(1, 1, .9, 1), AbsoluteLayoutFlags.All);
this.Spacing = 0;
this.Children.Add(_header);
this.Children.Add(_content);
_content.IsVisible = false;
_isExpanded = false;
_header.GestureRecognizers.Add(
new TapGestureRecognizer
{
Command = new Command(async () =>
{
if (_isExpanded)
{
_headerIcon.Source = _arrowRight;
//_content.HeightRequest = 0;
_content.IsVisible = false;
_isExpanded = false;
}
else
{
_headerIcon.Source = _arrowDown;
//_content.HeightRequest = _content.Children.Count * 70;
_content.IsVisible = true;
_isExpanded = true;
// Scroll top by the current Y position of the section
if (parent.Parent is VisualElement)
{
await parent.ScrollToAsync(0, this.Y, true);
}
}
})
}
);
}