我有一个集合说它NotificationHistoryCollection
是一个NotificationHistory
对象的集合,它又具有NotificationDetails
对象和集合NotificationHistoryDetail
。如何在 silverlight 4.0 中绑定NotificationDetails
到数据网格并将集合绑定到另一个数据网格NotificationHistoryDetail
问问题
212 次
1 回答
0
这应该给你一些想法:
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
friends.Add(new Friend(){Name = "Pappu",Email = new EmailAddress(){Email = "test@test.com"}});
dgFriends.ItemsSource = Friends;
}
ObservableCollection<Friend> friends = new ObservableCollection<Friend>();
public ObservableCollection<Friend> Friends { get { return friends; } set { friends = value; } }
}
public class Friend
{
public string Name { get; set; }
public string LastName { get; set; }
public EmailAddress Email { get; set; }
}
public class EmailAddress
{
public string Email { get; set; }
}
<data:DataGrid x:Name="dgFriends" AutoGenerateColumns="False">
<data:DataGrid.Columns>
<data:DataGridTextColumn Binding="{Binding Email.Email}" Header="EmailAddress" IsReadOnly="True"></data:DataGridTextColumn>
</data:DataGrid.Columns>
</data:DataGrid>
结果:
于 2012-10-19T08:06:01.893 回答