问题描述
我在我的每个 html 和 css 项目中都使用了 flex。
我在 XAML 中发现 在 flex 里面没有显示任何 flex 所以里面没有任何东西,但我可以看到它工作的东西。我在这里做错了什么在 xarmarin/xaml 中还是新的 Microsoft doc 也很基础 https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/flex-layout<ContentPage.Content>
<StackLayout>
<FlexLayout>
<FlexLayout>
<Label Text="It don't work"></Label>
</FlexLayout>
<Label Text="Is it work"></Label>
</FlexLayout>
</StackLayout>
</ContentPage.Content>
解决方法
我在 github 上找到一个讨论嵌套 FlexLayout 不可见的线程:
https://github.com/xamarin/Xamarin.Forms/issues/9537。
我还找到了一种解决方法,您可以将您的孩子的 flex 布局放入其中:
<StackLayout>
<FlexLayout>
<StackLayout WidthRequest="100">
<FlexLayout>
<Label Text="It don't work" />
</FlexLayout>
</StackLayout>
<Label FlexLayout.AlignSelf="Center" Text="Is it work" />
</FlexLayout>
</StackLayout>