代码:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:FlexLayout2"
x:Class="FlexLayout2.MainPage">
<FlexLayout
Direction="Column"
JustifyContent="Start"
AlignItems="Stretch">
<FlexLayout
Direction="Row"
JustifyContent="Start"
AlignItems="Stretch">
<BoxView Color="Red"/>
<BoxView Color="Black"/>
</FlexLayout>
<BoxView Color="Yellow"/>
</FlexLayout>
</ContentPage>
我得到了什么:
Image
我的期望:
Image
问题说明了一切。
我缺少什么?
Xamarin 表单 3.2
最佳答案
如果你把你的 child flex 布局放在 <ContentView>
里面它会起作用:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:FlexLayout2"
x:Class="FlexLayout2.MainPage">
<FlexLayout
Direction="Column"
JustifyContent="Start"
AlignItems="Stretch">
<ContentView>
<FlexLayout
Direction="Row"
JustifyContent="Start"
AlignItems="Stretch">
<BoxView Color="Red"/>
<BoxView Color="Black"/>
</FlexLayout>
</ContentView>
<BoxView Color="Yellow"/>
</FlexLayout>
</ContentPage>
关于xaml - 为什么在这种情况下看不到嵌套的 FlexLayout?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52486382/