I am trying to create a dynamic view, where I get the data from the backend and create views for it on my Xamarin App.
In the XAML view I have a simple stack layout
<StackLayout x:Name="Container">
</StackLayout>
and I am creating views as soon as the date is retrieved as so
Label label = new Label();
label.Text= Text;
label.LineHeight = 1.1;
Container.Children.Add(CreateLabel(label));
The problem is the view doesn't expand to fit all the elements added
calculating the height and setting it as the HeightRequest for stack layout didn't work
any idea or suggestion would be nice.
1条答案
按热度按时间tzxcd3kk1#
我通过编写MainPage.xaml.cs文件为您做了一个演示。
您可以看到我创建了一个StackLayout和一个标签,并将布局绑定到内容。它运行良好,您可以尝试一下。