WPF 自定义模板
?
<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);
??????????????? }?
?
?
?轉載于:https://www.cnblogs.com/quietwalk/archive/2011/08/03/2126565.html
總結
- 上一篇: 也议GetLastKnownLocati
- 下一篇: 【备忘】visual studio调试状