c# - Xamarin 中的 Flex 布局
问题描述
我在每个关于 html 和 css 的项目中都使用 flex。我在 XAML <flexlayout 中发现工作方式相同,所以我尝试
<ContentPage.Content>
<StackLayout>
<FlexLayout>
<FlexLayout>
<Label Text="It don't work"></Label>
</FlexLayout>
<Label Text="Is it work"></Label>
</FlexLayout>
</StackLayout>
</ContentPage.Content>
它在 flex 内部没有显示任何 flex,所以里面什么都没有,但我可以看到它工作的东西。我在这里做错了什么在 xarmarin/xaml 中还是新的
Microsoft doc 也是一种基本的https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/flex-layout
解决方案
我在 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>
推荐阅读
- css - 高度中的 CSS 按钮,带有 flexbox
- java - 输入已更新到数据库中的错误字段
- flutter - Flutter:如果数据为空,FutureBuilder 不会更新
- google-smart-home - 如何对 types.SHUTTER 进行分组,例如 types.LIGHT
- gdb - 时间表休息(
) gdb 调试功能不工作 - java - 将字符串转换为枚举以启用要读取的文件
- c# - 进程(outlook)启动时显示消息
- domain-driven-design - 谁以及如何处理重播事件?
- java - 在 selenium java 中处理右键单击菜单项
- json - 如何将逗号分隔的对象类型添加到 NgFor 循环中?