• 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);

                    }
     

     

  • 相关阅读:
    IsCallback和IsPostBack的区别
    win7 无Internet访问权限的解决方法
    Microsoft Office 2007的ContentType
    浏览器渲染原理
    css中hideFocus的用法
    js实现小球碰撞(数学之美)
    从浏览器的渲染原理讲CSS性能
    Jquery 常用方法经典总结
    web前端开发必备压缩工具整理
    15个精美PC/手机端自响应网页设计案例与欣赏
  • 原文地址:https://www.cnblogs.com/quietwalk/p/2126565.html
Copyright © 2020-2023  润新知