xamarin forms syncfusion ListView ItemAppearing



我使用syncfusion listview在xamarin表单上创建listview

我想在列表视图中使用ItemAppearing选项

我在网站上使用了这个例子:https://help.syncfusion.com/cr/cref_files/xamarin/Syncfusion.SfListView.XForms~ Syncfusion.ListView.XForms.SfListView.html

以及本例:https://help.syncfusion.com/cr/cref_files/xamarin/Syncfusion.SfListView.XForms~Syncfusion.ListView.XForms.SfListView~ItemAppearing_EV.html#ExampleBookmark

我用这个例子,发现这个问题

ListView.ItemAppearing +=listView_ItemAppearing;
public void listView_ItemAppearing(object sender, Syncfusion.ListView.XForms.ItemAppearingEventArgs e)
{
var temp= e.ItemData as IEnumerable<ListViewCall>;
//temp.ToList();
}

我将e.ItemData投射到List<ListViewCall>并获得null

e.ItemData有数据,但var tempnull

为什么会这样?

ItemData:当项从绑定数据源中出现时,获取ListViewItem的基础数据对象。

所以e.ItemData将返回绑定对象。与上面的示例一样,它将返回对象BookInfo

public void listView_ItemAppearing(object sender, Syncfusion.ListView.XForms.ItemAppearingEventArgs e)
{
var temp= e.ItemData as BookInfo;           
}
public void listView_ItemAppearing(object sender, Syncfusion.ListView.XForms.ItemAppearingEventArgs e)
{
if (e.ItemData is GroupResult)
{
var listViewCalls = (e.ItemData as GroupResult).Items as EnumerableQuery<ListViewCall>;
foreach (var listViewCall in listViewCalls)
{
}
}
else if (e.ItemData is ListViewCall)
{
var listViewCall = e.ItemData as ListViewCall;

}

// foreach (Object obj in e.ItemData.GetType().GetProperties(System.Reflection.BindingFlags.Public | BindingFlags.Instance))
// {
//    string s = (obj as Call).Title;
//}

}

相关内容

  • 没有找到相关文章

最新更新