<FlexLayout Direction="Row" JustifyContent="Start">
<circle:CircleImage
BackgroundColor="Blue"
Style="{StaticResource profileStyle}"
Source="{Binding TeacherSource}">
</circle:CircleImage>
<FlexLayout
FlexLayout.Grow="1"
Direction="Column"
BackgroundColor="Red"
JustifyContent="SpaceEvenly">
<Label Text="{Binding TeacherName}" Style="{DynamicResource ListItemTextStyle}"></Label>
<Label Text="{Binding TeacherEmail}" Style="{DynamicResource ListItemTextStyle}"></Label>
<Label Text="{Binding TeacherMobile}" Style="{DynamicResource ListItemTextStyle}"></Label>
<Label Text="{Binding TeacherHome}" Style="{DynamicResource ListItemTextStyle}"></Label>
<Label Text="{Binding TeacherWork}" Style="{DynamicResource ListItemTextStyle}"></Label>
</FlexLayout>
</FlexLayout>
以上xaml是在listview中使用的datatemplate内部创建的。我可以显示内容,但是最后一个标签没有扩展flexlayout以使其适合所有内容。
下图:
答案 0 :(得分:0)
我尝试了您的代码,但没有找到让flexlayout
自动扩展的解决方案。我尝试过ForceUpdateSize,但是没有运气。
如果只有一个FlexLayout
,它将起作用:
<FlexLayout
FlexLayout.Grow="1"
Direction="Column"
BackgroundColor="Red"
JustifyContent="SpaceEvenly">
<Label Text="{Binding TeacherName}" Style="{DynamicResource ListItemTextStyle}"></Label>
<Label Text="{Binding TeacherEmail}" Style="{DynamicResource ListItemTextStyle}"></Label>
<Label Text="{Binding TeacherMobile}" Style="{DynamicResource ListItemTextStyle}"></Label>
<Label Text="{Binding TeacherHome}" Style="{DynamicResource ListItemTextStyle}"></Label>
<Label Text="{Binding TeacherWork}" Style="{DynamicResource ListItemTextStyle}"></Label>
</FlexLayout>
我发现一个 Workaroud :
将您的flexLayout
更改为StackLayout
即可使用:
<FlexLayout Direction="Row" JustifyContent="Start">
<Image Source="Images"></Image>
<StackLayout Orientation="Vertical">
<Label Text="{Binding Name}"></Label>
<Label Text="{Binding Image}"></Label>
<Label Text="{Binding Image}"></Label>
<Label Text="{Binding Image}"></Label>
<Label Text="{Binding Image}"></Label>
</StackLayout>
</FlexLayout>
请记住设置您的listView
HasUnevenRows =“ True” ,不要设置rowheight
。