I'm new to Xamarin Forms, and I've met my first challenge. I want a Frame around my Stacklayout within a Listview. When the user selects an item in the Listview I want some controls to appear. This works fine without the Frame, but the Frame does not expand when the controls appear. How can I change or get around this behavior?
Since I simply cannot get the editor here to behave, my code is linked below:
pastebin-dot-com/QyzWPYsT
As a workaround , i add a tap gesture on viewcell and resize cell height .
<StackLayout> <ListView x:Name="listView" HasUnevenRows="True" ItemsSource="{Binding Items}" > <ListView.ItemTemplate> <DataTemplate> <ViewCell Tapped="ViewCell_Tapped"> <StackLayout BackgroundColor="Red"> <Frame BackgroundColor="White" BorderColor="Black"> <StackLayout BackgroundColor="Red"> <Label Text="{Binding Name}"></Label> <Entry Text="{Binding Details}" IsVisible="{Binding ShowDetails}"></Entry> </StackLayout> </Frame> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView> </StackLayout>
private void ViewCell_Tapped(object sender, EventArgs e) { var s = sender as ViewCell; ViewModelItem a = s.BindingContext as ViewModelItem; a.ShowDetails = !a.ShowDetails; if(a.ShowDetails == true) { s.Height += 100; } else { s.Height -= 100; } s.ForceUpdateSize(); }
@ColeX Thanks for the reply. I went with a similar, but slightly different approach:
https://stackoverflow.com/questions/54977809/xamarin-forms-frame-not-expanding-with-content/55023811
Answers
@foamster

1I think this video can help you.
Thanks for the answer, @Harshita but my problem is not expanding a Listview (that part works fine). It is expanding a frame that does not work..
what do you want? can you show it visualy?so that it will be helpfull for answering
I linked my code in the original question, you can see the effect if you copy it into a solution and run it..
As a workaround , i add a tap gesture on viewcell and resize cell height .
Xaml
Code behind
Refer https://github.com/xamarin/xamarin-forms-samples/blob/master/UserInterface/ListView/DynamicUnevenListCells/UnevenListCells/HomePage.xaml.cs
@ColeX Thanks for the reply. I went with a similar, but slightly different approach:
https://stackoverflow.com/questions/54977809/xamarin-forms-frame-not-expanding-with-content/55023811
i have the same problem here. Any solutions ?
i have 2 labels inside a Vertical stackview inside viewcell inside listview(hasUnevenRows=true)
label2 visibility is binding to item.isAnswerVisible as {Binding isAnswerVisible}
onItemClick, i change items isAnswerVisible to !isAnswerVisible
Obviously label2 obeys binding and changes visibility
(i could understand that because it renders itself out of stackView and View Cell over below viewCell )
but stackView surrounding labels , can not detect visibility change and does not change its height
First stackview was surrounded with frame. i thought frame was the problem and comment it out.
But seems to be stackview is the problem
Problem seems to be not about binding. Binding works. i could see that
Problem seems to be stackView not realizing children changing visibilities.
Varios Fill and FillANdExpand combinations tried for VerticalOptions for all elements.
Not working.
ListView is inside Absolute Layout
using XamarinForms 4.1.06....