gpt4 book ai didi

c# - 使用 UnevenRows 更新 TableView 中的 ViewCell 无法正常工作 Xamarin.Forms

转载 作者:行者123 更新时间:2023-11-29 05:31:06 25 4
gpt4 key购买 nike

TableView 中充满了如此多的 ViewCell,因此您必须滚动页面才能看到最后一个 ViewCell。如果您随后通过 Taped-Event 更新最后一个 ViewCell(更改标签的文本),则 label.Text 将不会更新..

PS:ForceUpdateSize 无法解决问题,因为在 iOS 上应用程序会在第六次卡住。

<TableView Intent="Settings" HasUnevenRows="True">
<TableRoot>
<TableSection>
<ViewCell x:Name="DefaultViewCell" Tapped="ItemTapped">
<StackLayout>
<Label x:Name="DefaultLabel" />
</StackLayout>
</ViewCell>
<!--.....-->
</TableSection>
</TableRoot>
</TableView>

最佳答案

我测试了你的示例代码,确实发生了你描述的现象。 虽然在Android中不会发生,但在IOS中却发生了。也许IOS和Android之间的Label有一些差异。

最后,我在IOS中找到了解决方案。您可以将默认的Text值设置为Label,然后Tapped方法就可以工作。

如下:

<TableView Intent="Settings" HasUnevenRows="True" BackgroundColor="Accent" >
<TableRoot>
<TableSection>
<ViewCell x:Name="DefaultViewCell" Tapped="DefaultViewCell_Tapped">
<StackLayout>
<Label x:Name="DefaultLabel" Text="Default Text "/>
</StackLayout>
</ViewCell>
...
</TableSection>
</TableRoot>
</TableView>

enter image description here

关于c# - 使用 UnevenRows 更新 TableView 中的 ViewCell 无法正常工作 Xamarin.Forms,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57557622/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com