【问题标题】:List within List in Xamarin.forms xamlXamarin.forms xaml 中的列表中的列表
【发布时间】:2016-04-12 08:22:50
【问题描述】:

我有一个字典,其中的值是字符串列表。在我的 xaml 中,我将字典绑定到一个列表,并在该列表中打印出密钥。然后我想打印出每个键的值列表。我应该绑定什么到值列表,我应该绑定什么到值标签?

这是我的 xaml:

<ListView x:Name ="QuoteListView" ItemsSource ="{Binding dict}" HasUnevenRows="True">
    <ListView.ItemTemplate>
      <DataTemplate >
        <ViewCell >
          <ViewCell.View >
            <StackLayout>
              <StackLayout Orientation="Horizontal" Padding="10">
                <Label Text ="{Binding Key}" FontSize="10" FontAttributes="Bold" TextColor="White" />
              </StackLayout>
              <StackLayout Orientation="Horizontal" Padding="10">
                <ListView x:Name ="QuoteTextListView" ItemsSource ="{Binding }" HasUnevenRows="True">
                <Label Text ="{Binding }" FontSize="10" TextColor="White"/>
                </ListView>
              </StackLayout>
            </StackLayout>
          </ViewCell.View>
        </ViewCell>
      </DataTemplate>
    </ListView.ItemTemplate>
  </ListView>

这就是我想要实现的目标:

名字 1

“引用 1 个文本”

“引用 2 文本”

名字 2

“引用 1 个文本”

“引用 2 文本”

...

【问题讨论】:

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


【解决方案1】:

我建议使用ListView 分组。您可以将您的字典变成 2 个列表。 ListView分组信息可以在here找到。

基本上,您将创建一个对象来存储引用字符串的列表。然后,您将该对象放入另一个表示名称列表的对象中。如果您有任何问题,请告诉我。

【讨论】:

  • 您能否举例说明一下。我有同样的问题。我列出了哪个 itemsource 类里面有另一个列表。如何在我的列表中绑定它。??
  • @NeelamPrajapati 查看link
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-01-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多