Tôi đang cố gắng đưa một ListView từ một dữ liệu. Trong file XAML của tôi, tôi đã viếtkhông chứa các phần tử trong các biểu mẫu xamarin cho listview
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="FormDemos.Views.Feedback">
<ContentPage.Content>
<Label>I am Testimonials Page</Label>
<ListView x:Name="FeedbackList" />
</ContentPage.Content>
</ContentPage>
Trong tập tin CS
namespace FormDemos.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Feedback : ContentPage
{
class City
{
public string Name
{
get;
set;
}
public string State
{
get;
set;
}
}
public Feedback()
{
InitializeComponent();
var cities = new List<City>() {
new City() {State = "FL", Name = "Miami"},
new City() {State = "CA", Name = "San Francisco"},
new City() {State = "CA", Name = "Los Angeles"},
new City() {State = "FL", Name = "Orlando"},
new City() {State = "TX", Name = "Houston"},
new City() {State = "NY", Name = "New York City"},
};
FeedbackList.ItemsSource = cities;
}
}
}
Mỗi lần tôi xây dựng dự án này tôi nhận được lỗi "Trình tự không chứa yếu tố". Tôi đã thấy một số hướng dẫn trực tuyến có cùng mã và chạy tốt. Có gì sai ở đây?