CollectionView Header 在 iOS 上忽略了左边距。

huangapple go评论76阅读模式
英文:

CollectionView Header ignores left margin on iOS

问题

我有一个 .net maui 应用程序,其中包含一个标题:

<CollectionView.Header>
    <VerticalStackLayout Margin="18,0,18,12">
        <Label Style="{StaticResource TextBodySecondary}"
               Text="{Binding TotalExpenses, StringFormat={extensions:Translate TotalExpenseTemplate}, Converter={StaticResource AmountFormatConverter}}" />
        <Label Style="{StaticResource TextBodySecondary}"
               Text="{Binding TotalRevenue, StringFormat={extensions:Translate TotalRevenueTemplate}, Converter={StaticResource AmountFormatConverter}}" />
    </VerticalStackLayout>
</CollectionView.Header>

在 Android 和 Windows 上,文本具有适当的边距。但在 iOS 上,边距被忽略。

有趣的是,当我更改一些内容时,热重载实际上可以进行修正。这是已知的 maui 问题吗?是否有一种解决方法?

CollectionView Header 在 iOS 上忽略了左边距。

英文:

I have .net maui application with a header:

        <CollectionView.Header>
            <VerticalStackLayout Margin="18,0,18,12">
                <Label Style="{StaticResource TextBodySecondary}"
                       Text="{Binding TotalExpenses, StringFormat={extensions:Translate TotalExpenseTemplate}, Converter={StaticResource AmountFormatConverter}}" />
                <Label Style="{StaticResource TextBodySecondary}"
                       Text="{Binding TotalRevenue, StringFormat={extensions:Translate TotalRevenueTemplate}, Converter={StaticResource AmountFormatConverter}}" />
            </VerticalStackLayout>
        </CollectionView.Header>

On Android and Windows the text has a proper margin. On iOS the margin is ignored.

CollectionView Header 在 iOS 上忽略了左边距。

Funny enough, when I change something hot reload does it actually correct. Is that a known maui issue? And is there a work around?

答案1

得分: 1

我可以重现在iOS上忽略`Margin`的问题。作为一个替代性的解决方法,你可以将你的`VerticalStackLayout`包裹在一个`ContentView`中,然后`Margin`将按预期工作。

你可以参考下面的示例代码:
英文:

I can reproduce the issue that the Margin is ignored on iOS. As an alternative workaround, you can wrap your VerticalStackLayout in a ContentView, then the Margin will work as expected.

You can refer to the sample code below:

<CollectionView.Header>
      <ContentView>
            <VerticalStackLayout Margin="18,0,18,12">
                <Label Style="{StaticResource TextBodySecondary}"
                       Text="{Binding TotalExpenses, StringFormat={extensions:Translate TotalExpenseTemplate}, Converter={StaticResource AmountFormatConverter}}" />
                <Label Style="{StaticResource TextBodySecondary}"
                       Text="{Binding TotalRevenue, StringFormat={extensions:Translate TotalRevenueTemplate}, Converter={StaticResource AmountFormatConverter}}" />
            </VerticalStackLayout>
     </ContentView>
</CollectionView.Header>

huangapple
  • 本文由 发表于 2023年7月18日 01:23:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76706782.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定