简体   繁体   中英

List view does not contain a definition for 'ItemsSource' in Xamarin.forms?

I am new to c# Cross-Platform working in xamarin.forms in visual studio. Copied sample code from this link , getting some error like definition can't be found. Can anyone please give any solution or idea why i am getting this error and what i have missed in it.

Main.cs

        ListView listView = new ListView
        {
            ItemsSource = presidents,
            ItemTemplate = cell // Set the ImageCell to the item template for the listview
        };

i am getting error in this above line in the copied code from the above link.

It looks like you are using Android.Widget.ListView. You need to use Xamarin.Forms.ListView Class.

First, you should post your whole code here and also post the exact error-message (as it is not possible else to give you an exact answer).
I think, you don't have overtaked the whole code form the example...?
So, maybe presidents and/or cell is not found.
If this is not the problem, you can find (another) example (with description) to the use of LstViews here: How to use ListView

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM