gpt4 book ai didi

c# - TableView Viewcell Tapped Action

转载 作者:行者123 更新时间:2023-11-30 23:23:31 30 4
gpt4 key购买 nike

如何使用 ViewCell 中的 Tapped 操作导航到其他页面?

Xmal代码

<TableView Intent="Settings" HasUnevenRows="true" VerticalOptions="StartAndExpand" BackgroundColor="White" >
<TableRoot>
<TableSection>
<ViewCell Height="100" Tapped="OnProfileClicked">
<ViewCell.View>
<StackLayout Orientation="Horizontal" Padding="5,2,5,2" BackgroundColor="White" >

<Image x:Name="ImgProfile" HeightRequest="100"/>
<Label x:Name="btnName" VerticalOptions="Center" TextColor="Black" FontSize="20"/>
<Label Text="> " FontSize="15" HorizontalOptions="EndAndExpand" VerticalOptions="Center"/>

</StackLayout>
</ViewCell.View>

</ViewCell>

</TableSection>
</TableRoot>
</TableView>

CS文件

    public void onProfileTapped()
{
Navigation.PushAsync(new Clubs());
}

最佳答案

所以您的代码有几处错误。

1.) 你写了 Tapped=OnProfileClicked 但是你实际创建的方法叫做 onProfileTapped(),这是不匹配的

2.) 项目点击事件的参数错误,大多数 Xamarin 事件都包含发送者和 eventArgs。

以下是修复代码以使其正常工作的方法:

void OnProfileClicked (object sender, System.EventArgs e) { //your code}

此外,提示,当您使用导航推送页面时。您可能希望将方法标记为异步并等待操作以确保它是平稳过渡。

关于c# - TableView Viewcell Tapped Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38342694/

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