xamarin形成同步融合ListView ItemAppearing

时间:2019-10-31 15:03:24

标签: xamarin xamarin.forms cross-platform syncfusion xamarin.forms-styles

我使用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

为什么会这样?

2 个答案:

答案 0 :(得分:0)

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

因此e.ItemData将返回绑定对象。像上面的示例一样,它将返回对象BookInfo

public void listView_ItemAppearing(object sender, Syncfusion.ListView.XForms.ItemAppearingEventArgs e)
    {
       var temp= e.ItemData as BookInfo;           
    }

答案 1 :(得分:0)

           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;
        //}


    }