C# Xamarin-点击时如何从listview中的ImageCell获取数据绑定字符串值?
我对Xamarin还不熟悉,我在弄清楚如何获得图像单元格的绑定值时遇到了一个问题 我有一个使用ImageCell的列表视图,如下所示,iv'e将itemSelected命令设置为名为“selectedBox\u”的列表视图 我希望能够从ImageCell获取{Binding Name}的字符串值,然后将其作为构造函数传递给我的DetailsPage,如上所示 其中String name=??我不知道需要做些什么才能使这项工作正常进行C# Xamarin-点击时如何从listview中的ImageCell获取数据绑定字符串值?,c#,listview,xamarin,xamarin.forms,xamarin.android,C#,Listview,Xamarin,Xamarin.forms,Xamarin.android,我对Xamarin还不熟悉,我在弄清楚如何获得图像单元格的绑定值时遇到了一个问题 我有一个使用ImageCell的列表视图,如下所示,iv'e将itemSelected命令设置为名为“selectedBox\u”的列表视图 我希望能够从ImageCell获取{Binding Name}的字符串值,然后将其作为构造函数传递给我的DetailsPage,如上所示 其中String name=??我不知道需要做些什么才能使这项工作正常进行 感谢您的帮助:)使用ItemTappedEventArgs p
感谢您的帮助:)使用
ItemTappedEventArgs
private async void selectedBox_Tapped(object sender, ItemTappedEventArgs args)
{
// args.Item will be the context of the tapped cell
// you will need to cast it to the correct class
var item = (MyClass)args.Item;
// once item is cast, you can just refer to its properties
await Navigation.PushAsync(new DetailsPage(item.Name));
}
使用
ItemTappedEventArgs
private async void selectedBox_Tapped(object sender, ItemTappedEventArgs args)
{
// args.Item will be the context of the tapped cell
// you will need to cast it to the correct class
var item = (MyClass)args.Item;
// once item is cast, you can just refer to its properties
await Navigation.PushAsync(new DetailsPage(item.Name));
}
非常感谢。工作得很有魅力:)谢谢!工作得很有魅力:)
private async void selectedBox_Tapped(object sender, ItemTappedEventArgs args)
{
// args.Item will be the context of the tapped cell
// you will need to cast it to the correct class
var item = (MyClass)args.Item;
// once item is cast, you can just refer to its properties
await Navigation.PushAsync(new DetailsPage(item.Name));
}