思考、创新、坚持、执行

如果创新能改变人类的消费习惯,那么将对它所进入的领域产生深远影响,进而成就一家伟大的世界级企业;云翻译平台www.139fanyi.com.cn要去一切中心化

 

Silverlight的ListBox和DataGrid绑定

Demo1 

前台:<my:DataGrid x:Name="GridPerson" AutoGenerateColumns="False" AlternatingRowBackground="Blue" GridlinesVisibility="All"    Width="400" Height="300" Canvas.Top="10" Canvas.Left="10">
 <my:DataGrid.Columns>
     <my:DataGridTextBoxColumn Header="Id" DisplayMemberBinding="{Binding Id}"  ></my:DataGridTextBoxColumn>
     <my:DataGridTextBoxColumn Header="Name" DisplayMemberBinding="{Binding Name}" ></my:DataGridTextBoxColumn>
      <my:DataGridTextBoxColumn Header="Email" DisplayMemberBinding="{Binding Email}" ></my:DataGridTextBoxColumn>
       <my:DataGridTemplateColumn Header="Del">
              <my:DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                           <TextBox Text="{Binding Email}"></TextBox>
                    </DataTemplate>
              </my:DataGridTemplateColumn.CellTemplate>
        </my:DataGridTemplateColumn>
   </my:DataGrid.Columns>
</my:DataGrid>

后台:

 void BindData()
        {
            System.Collections.Generic.List<PersonInfo> personlist = new List<PersonInfo>();

            personlist.Add(new PersonInfo() { Id="0008", Name="陈国成8", Email="guocheng.chen8@rising.com" });
            personlist.Add(new PersonInfo() { Id = "0001", Name = "陈国成1", Email = "guocheng.chen1@rising.com",Deleted=true });
            personlist.Add(new PersonInfo() { Id = "0002", Name = "陈国成2", Email = "guocheng.chen2@rising.com", Deleted = true });
            personlist.Add(new PersonInfo() { Id = "0003", Name = "陈国成3", Email = "guocheng.chen3@rising.com", Deleted = false });
            this.GridPerson.ItemsSource = personlist;
        }

Demo2

<ListBox x:Name="LstPerson">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Name}"></TextBlock>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox> 

 

this.LstPerson.ItemsSource = personlist;

 

posted on 2008-04-11 17:27  铭天  阅读(2129)  评论(1编辑  收藏  举报

导航

中国翻译公司| 北京翻译公司| 北京翻译公司| 语通全球翻译公司| 同声传译|