【问题标题】:Maui Community Toolkit - UniformItemsLayout - only first StackLayout showingMaui Community Toolkit - UniformItemsLayout - 仅显示第一个 StackLayout
【发布时间】:2023-01-16 17:35:48
【问题描述】:

在我的 UniformItemsLayout 中显示多个 StackLayout 时遇到问题。我没有更改我的代码,因为它正在工作,唯一的区别是我从某个 1.X 版本更新到 3.1,现在只有第一个孩子出现在堆栈布局中。

<toolkit:UniformItemsLayout MaxColumns="2" >
            <StackLayout Orientation="Vertical">
                <Label Text="Test1"/>
                <Button Text="TestA"/>
            </StackLayout>
            <StackLayout Orientation="Vertical">
                <Label Text="Test2"/>
                <Button Text="TestB"/>
            </StackLayout>
            <StackLayout Orientation="Vertical">
                <Label Text="Test3"/>
                <Button Text="TestC"/>
            </StackLayout>
            <StackLayout Orientation="Vertical">
                <Label Text="Test4"/>
                <Button Text="TestD"/>
            </StackLayout>
            <StackLayout Orientation="Vertical">
                <Label Text="Test5"/>
                <Button Text="TestE"/>
            </StackLayout>
</toolkit:UniformItemsLayout>

当我只使用标签进行测试时,它似乎没问题,但只要我添加多个堆栈布局,就只会显示第一个。

【问题讨论】:

  • 请问你是在什么平台上测试的?我参考你的代码在Windows上测试过,在VS2022 17.4.2中可以正常显示,但是如果StackLayout使用Vertical,它的布局看起来会有点奇怪,但是使用@987654324就可以完美显示了@.
  • 我主要在 Android 上工作,但当然我希望它适用于所有平台,因为我计划在 Android 以外的平台上发布我的应用程序。我将尝试水平放置 - 我使用的是版本 17.5.0 预览版 2.0。我想我总是喜欢更新以获得最多的功能和修复,但在某些时候我想我应该为了应用程序而停下来。
  • 在 Android 的全新内容页面上使用水平方向的 Stacklayouts 结果相同。我什至创建了一个新的 maui 项目并为 CommunityToolkit 添加了最新的 Nuget 包并经历了同样的事情。我什至试图恢复我的 Nuget 包版本,但项目无法恢复到原来的状态。猜猜我现在运气不好使用这个工具。

标签: c# maui stacklayout maui-community-toolkit


【解决方案1】:

我创建了一个新示例来测试您的代码。我已经尝试了 CommunityToolkit.Maui 包,从 1.0.0 版本到 3.1.0 版本。没有一个版本可以在 android 上显示 UniformItemsLayout 中的所有堆栈布局。

在 Windows 上,它会显示所有堆栈布局,但 UI 看起来很奇怪。但是如果删除StackLayout,所有控件都会显示。如:

<toolkit:UniformItemsLayout MaxColumns="2" >
         
                <Label Text="Test1"/>
                <Button Text="TestA"/>
           
                <Label Text="Test2"/>
                <Button Text="TestB"/>
           
                <Label Text="Test3"/>
                <Button Text="TestC"/>
            
                <Label Text="Test4"/>
                <Button Text="TestD"/>
            
                <Label Text="Test5"/>
                <Button Text="TestE"/>

</toolkit:UniformItemsLayout>

它应该是android上的一个错误。你可以举报on the github

【讨论】:

    猜你喜欢
    • 2022-08-04
    • 1970-01-01
    • 2022-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多