当我在列表视图中使用 TextCell 时,列表视图项为空

When I used TextCell in listview, listview items are nulls

在我的页面中,我使用 Listview,它显示目录中的文件名。

当我在 Listview 中使用 TextCell 时,Listview 项为空。

我的 Listview 项代码是:

            DirectoryInfo di = new DirectoryInfo(myDirectory);
            FileInfo[] files = di.GetFiles();

            if (Directory.Exists(myDirectory))
            {
                for (int i = 0; i < files.Length; i++)
                {
                    lstFiles.Add(i + 1 + ". " + files[i].Name);
                }
            }
            lstviewsFile.ItemsSource = lstFiles;

我的xaml:

你能帮帮我吗?

lstFiles 是您的 ItemsSource - 列表中的每一行只是一个字符串(大概,您实际上并没有显示该代码)

所以你的绑定应该是

<TextCell Text="{Binding .}" ... />