【问题标题】:List view does not contain a definition for 'ItemsSource' in Xamarin.forms?列表视图不包含 Xamarin.forms 中“ItemsSource”的定义?
【发布时间】:2017-01-14 14:12:31
【问题描述】:

我是 c# Cross-Platform 的新手,在 Visual Studio 的 xamarin.forms 中工作。从此link 复制了示例代码,出现了一些错误,例如找不到定义。谁能提供任何解决方案或想法,为什么我会收到此错误以及我错过了什么。

Main.cs

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

我在上述链接中复制的代码中的上述行中出现错误。

【问题讨论】:

  • 您确定您引用的是 Xamarin ListView 而不是本机 C#t ListView?

标签: c# android xamarin.ios xamarin.forms


【解决方案1】:

看起来您正在使用 Android.Widget.ListView。您需要使用 Xamarin.Forms.ListView 类。

【讨论】:

    【解决方案2】:

    首先,您应该在此处发布您的整个代码并发布确切的错误消息(因为不可能给您一个准确的答案)。
    我认为,您没有超越示例中的整个代码...?
    所以,也许没有找到总统和/或单元格。
    如果这不是问题,您可以在此处找到(另一个)使用 LstViews 的示例(带说明):How to use ListView

    【讨论】:

      猜你喜欢
      • 2022-01-06
      • 2016-05-15
      • 2016-12-31
      • 2015-10-16
      • 2015-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-08
      相关资源
      最近更新 更多