访问 selectedItem xamarin 表单的属性 [英] access properties of the selectedItem xamarin forms
本文介绍了访问 selectedItem xamarin 表单的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试访问列表中的属性{Name},例如使用 slectedItem.
Trying to access the property{Name} inside a list , using slectedItem ex.
var SName = e.SelectedItem;
if (e.SelectedItem == null)
{
return;
}
await DisplayAlert("Item Selected", SName.ToString(), "Ok");
常用的方法是 var SName = e.SelectedItem.Name;.但是我没有选择访问它.我已经有了 get;set;如果我在提及行上添加一个断点,它会显示我想要显示的 Name 属性和值.有什么建议吗?谢谢
the common way will be just var SName = e.SelectedItem.Name;. However I dont get the option to access it . I already have the get;set; and if I add a breakpoint on the mention line it shows me the Name property and value that I want to display. any suggestion ? Thanks
推荐答案
e.SelectedItem
属于 object
类型 - 您需要先将其转换为适当的类型
e.SelectedItem
is of type object
- you need to cast it to the appropriate type first
var item = (MyType) e.SelectedItem;
var name = item.Name;
这篇关于访问 selectedItem xamarin 表单的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文