我对联系人列表有以下用户控件
<UserControl.Content>
<Border BorderBrush="LightBlue" BorderThickness="1,1,1,1" CornerRadius="8,8,8,8" HorizontalAlignment="Left" VerticalAlignment="Top" Width="250" Height="300" Margin="0,0,-1,0">
<ItemsControl ItemsSource="{Binding Users}" x:Name="tStack" Grid.Column="0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" Height="Auto" Width="Auto" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<MenuItem MouseDoubleClick="MenuItem_MouseDoubleClick_1" Header="{Binding Username}">
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" FlowDirection="LeftToRight" Orientation="Vertical">
<Image Width="20" Height="20" Source="C:\Users\JR-WORK\Documents\Visual Studio 2012\Projects\itControl Chat\itControl Chat\Images\green-bullet.png" />
<TextBlock Text="{Binding Username}" />
</StackPanel>
</MenuItem>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Border>
</UserControl.Content>
这很好用,并且user
在我ObservableCollection
的Users
. 现在我想添加另一个ObservableCollection
用户组,比如朋友、组、收藏夹等等。如何在另一个绑定中分层以在列表中创建列表?我是否需要创建另一个UserControl
包含这个作为数据模板的模板?