英文:
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 问题吗?是否有一种解决方法?
英文:
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.
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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论