CompositeCollection

允许将多个集合和项作为一个列表显示

<ListBox Name="myListBox" Height="300" Width="200" Background="White">
      <ListBox.ItemsSource>
        <CompositeCollection>
          <CollectionContainer
            Collection="{Binding Source={StaticResource GreekGodsData}}" />
          <CollectionContainer
            Collection="{Binding Source={StaticResource GreekHeroesData}}" />
          <ListBoxItem Foreground="Red">Other Listbox Item 1</ListBoxItem>
          <ListBoxItem Foreground="Red">Other Listbox Item 2</ListBoxItem>
        </CompositeCollection>
      </ListBox.ItemsSource>
    </ListBox>

 

上一篇:WPF进阶技巧和实战03-控件(5-列表、树、网格01)


下一篇:【C#】向ListBox中添加删除文本