<Window.Resources>
<!--列表模板-->
<!--<DataTemplate x:Key="MyTemplate" DataType="{x:Type demo:MyProject}">-->
<DataTemplate x:Key="MyTemplate" >
<Grid VerticalAlignment="Center" HorizontalAlignment="Center" Margin="4,4,4,4" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Image Source="{Binding Photo}" Width="50" Height="50" Grid.Column="0" Grid.RowSpan="1"/>
<TextBlock Text="{Binding Name}" Grid.Column="1" Grid.ColumnSpan="1" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</DataTemplate>
</Window.Resources>
<Grid>
<ListBox x:Name="ListBox1" ItemTemplate="{StaticResource MyTemplate}"/>
</Grid>
List<TeamClient.Pages.ClientProjectMemberRole> ls = new List<ClientProjectMemberRole>();
foreach (MyMember myMember in memberCollection)
{
TeamClient.Pages.ClientProjectMemberRole clientMemberRole = new ClientProjectMemberRole();
clientMemberRole.MemberName = myMember.Name;
Project proj = service.GetProjectByName(projectName);
ProjectMember projMember = service.GetProjectMemberByMemberIdAndProjectId(myMember.Id, proj.Id);
clientMemberRole.RoleName = projMember.MemberRole.Name;
ls.Add(clientMemberRole);
}