如何使用Caliburn.Micro将容器绑定到MVVM标准中的listview控件?

我正在使用Caliburn.Micro库编写MVVM (C#)和XAML程序。

我想知道如何将Listview控件与ListIEnumerableObservableCollection等容器绑定?

查看\ MainView.xaml

             

的ViewModels \ MainViewModel.cs

 namespace ListBox_CaliburnMicro { public class MainViewModel : Screen { // ... public MainViewModel() { } public class FileItem { public string FileStatus { get; private set; } public string FileName { get; private set; } public string FileSize { get; private set; } public string FileType { get; private set; } public string FileEmailCount { get; private set; } public string FileInfoCount { get; private set; } public FileItem(string s1 = "", string s2 = "", string s3 = "", string s4 = "", string s5 = "", string s6 = "") { FileStatus = s1; FileName = s2; FileSize = s3; FileType = s4; FileEmailCount = s5; FileInfoCount = s6; } } } } 

首先,您应该在XAML上为您的财产编写标记。 让我们的形象:

模型:

 public class Person { public int IdPerson { get; set; } public string Name { get; set; } public string SurName { get; set; } } 

视图模型:

 public class MainWindowViewModel : INotifyPropertyChanged { public MainWindowViewModel() { FillData(); } private void FillData() { persons = new ObservableCollection(); for (int i = 0; i < 30; i++) { persons.Add(new Person() { IdPerson = i, Name = "Ben & Joseph " + i.ToString(), SurName = "Albahari" }); } } private ObservableCollection persons; public ObservableCollection Persons { get { return persons; } set { persons = value; } } public event PropertyChangedEventHandler PropertyChanged; public void OnPropertyChanged(string propertyName) { if(PropertyChanged!=null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } 

更新:

XAML: