码迷,mamicode.com
首页 > 其他好文 > 详细

SilverIight数据绑定实例

时间:2016-09-18 22:08:46      阅读:93      评论:0      收藏:0      [点我收藏+]

标签:

 

技术分享技术分享技术分享

前台Code

<DataGrid Name="DataGrid1" AutoGenerateColumns="False" IsReadOnly="True" Width="550">
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="100"/>
<DataGridTextColumn Header="Age" Binding="{Binding Age}" Width="100"/>
<DataGridTextColumn Header="Address" Binding="{Binding Address}" Width="100"/>
<DataGridTextColumn Header="Date" Binding="{Binding Date}" Width="200"/>
</DataGrid.Columns>
</DataGrid>

 

 

后台

public class Person
{
public String Name { get; set; }
public int Age { get; set; }
public String Address { get; set; }
public DateTime Date { get; set; }
}
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
var persons = new List<Person>();
for (var i = 0; i < 5; i++)
{
persons.Add(new Person { Name = "Person " + i.ToString(), Age = 20 + i, Address = "Address", Date=DateTime.Now });
}
DataGrid1.ItemsSource = persons;
}
}

SilverIight数据绑定实例

标签:

原文地址:http://www.cnblogs.com/aaaaq/p/5883073.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!